首页上一页 1 下一页尾页 1 条记录 1/1页
在创建数据库表时出错
发表在Python图书答疑
2019-04-20 悬赏:1 学分
《Python从入门到项目实践》第29章 e起去旅行网站
是否精华
是
否
版块置顶:
是
否
使用的都是书中自带的代码
manage.py
from app import create_app, db from app.models import* from flask_script import Manager, Shell from flask_migrate import Migrate, MigrateCommand from flask import render_template app = create_app('default') manager = Manager(app) migrate = Migrate(app,db) def make_shell_context(): return dict(app=app, db=db) manager.add_command("shell", Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) @app.errorhandler(404) def page_not_found(error): """ 404 """ return render_template("home/404.html"),404 if __name__ =='__name__ : manager.run()
app\__init__.py
from flask import Flask from flask_sqlalchemy import SQLAlchemy from config import config db = SQLAlchemy() def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) db.init_app(app) form app.home import home as home_blueprint form app.admin import admin as admin_blueprint app.register_blueprint(home_blueprint) app.register_blueprint(admin_blueprint,url_prefix="/admin") return app
于2019-04-20 11:55:46编辑