获取 Flask 对象在 flask fab create-user 上没有属性 'appbuilder'

Getting Flask object has no attribute 'appbuilder' on flask fab create-user

我试图使用 flask fab 从终端创建一个新用户,但是当我 运行 命令并填写所有必需的信息时,如 usernameemailpassword 我收到此错误消息:AttributeError: 'Flask' object has no attribute 'appbuilder'.

完整追溯:

https://pastebin.com/gACSfChG

FLASK_APP=run.py

run.py

import os

from app import RubyAPP

config_name = os.getenv('FLASK_CONFIG')
app = RubyAPP(config_name).app()

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')

__init__.py

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
from flask_login import current_user
from flask import render_template

db = SQLAlchemy()
app = Flask(__name__, instance_relative_config=True)
login_manager = LoginManager(app)

@app.errorhandler(404)
def not_found_404(e):
    return render_template('404.html'), 404

class RubyAPP(object):

    def __init__(self, config_name):
        # App manager
        app.config.from_pyfile('config.py')
        db.init_app(app)

        # Login manager
        login_manager.init_app(app)
        login_manager.login_message = 'You must be logged in to access this page'
        login_manager.login_view = 'auth.login'

        # Flask migrate
        migrate = Migrate(app, db)

    def app(self):
        # Error handling apps registers
        app.register_error_handler(404, not_found_404)

        # Models
        from app import models

        # Views
        from .home import home as home_blueprint
        app.register_blueprint(home_blueprint)

        from .profile.links import links as links_blueprint
        app.register_blueprint(links_blueprint)

        from .login import login as login_blueprint
        app.register_blueprint(login_blueprint)

        return app

我尝试重新安装 appbuilder 但出现了同样的错误。我认为这 2 个文件就足够了,但由于我不知道是什么导致了错误,如果您需要任何额外的文件,请告诉我。

有同样的错误。您的应用必须 运行 appbuilder.init_app():

..
..
class RubyAPP(object):
    def __init__(self, config_name):
        # App manager
        app.config.from_pyfile('config.py')
        db.init_app(app)

        with app.app_context():
            appbuilder.init_app(app, db.session)
..
..