新手Flask遇到问题求帮助,新手Flask遇到问题,错误提示如下:Trace


错误提示如下:

Traceback (most recent call last): File
"/Users/duzhipeng/project/manage.com/run.py", line 3, in

app = create_app() File "/Users/duzhipeng/project/manage.com/app/init.py", line 11,
in create_app
db.init_app(app) TypeError: init_app() missing 1 required positional argument: 'app'

Process finished with exit code 1

其中,run.py:

from app import create_appapp = create_app()if __name__ == '__main__':    app.run(debug=True)

另一个文件:app/init.py:

from flask import Flaskfrom flask.ext.sqlalchemy import SQLAlchemydb = SQLAlchemydef create_app():    app = Flask(__name__)    app.config.from_object('config')    db.init_app(app)    from . import views as manage_blueprint    app.register_blueprint(manage_blueprint)    return app

这次真的不明白错哪了,看了好些资料了。

没有实例 SQLAlchemy 创建db对象。改成下面即可

db = SQLAlchemy()

编橙之家文章,

评论关闭