python
config_error
ai_generated
true
断言错误:蓝图不能注册多次。
AssertionError: A blueprint cannot be registered more than once
ID: python/flask-blueprint-registration
80%修复率
84%置信度
0证据数
2025-06-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
在Flask应用中重复注册同一个蓝图实例。
English
在Flask应用中重复注册同一个蓝图实例。
解决方案
-
95% 成功率
只注册一次: from blueprints import auth_bp app.register_blueprint(auth_bp) # 不要再次注册
-
90% 成功率
每次创建新实例: auth_bp = Blueprint('auth', __name__) app.register_blueprint(auth_bp)
无效尝试
常见但无效的做法:
-
60% 失败
尝试创建新蓝图但使用了相同名称。
-
80% 失败
在多个文件中导入并注册同一蓝图。