from flask import Blueprint admin = Blueprint('admin',__name__) def init_bule(app): app.register_blueprint(blueprint=admin)
创建一个蓝图,执行程序发现有出现错误,一直启动不起
Traceback (most recent call last): File "manage.py", line 9, in <module> manage = Manager(app=create_app()) File "D:xuniflask_llbApp\__init__.py", line 18, in create_app init_bule(app) File "D:xuniflask_llbAppadminviews.py", line 7, in init_bule app.register_blueprint(blueprint=admin) File "D:xuniflask_weblibsite-packagesflaskapp.py", line 67, in wrapper_func return f(self, *args, **kwargs) File "D:xuniflask_weblibsite-packagesflaskapp.py", line 1103, in register_blueprint if blueprint.name in self.blueprints: AttributeError: 'function' object has no attribute 'name'
AttributeError: 'function' object has no attribute 'name'
后来发现是因为 蓝图名字和系统名字出现重叠,改动即可
_admin = Blueprint('admin',__name__) def init_bule(app): app.register_blueprint(blueprint=_admin)
增加一个下划线 _ 避免重复系统名