python config_error ai_generated true

AssertionError: A blueprint cannot be registered more than once

ID: python/flask-blueprint-registration

Also available as: JSON · Markdown · 中文
80%Fix Rate
84%Confidence
0Evidence
2025-06-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

在Flask应用中重复注册同一个蓝图实例。

generic

中文

在Flask应用中重复注册同一个蓝图实例。

Workarounds

  1. 95% success
    只注册一次:
    from blueprints import auth_bp
    app.register_blueprint(auth_bp)
    # 不要再次注册
  2. 90% success
    每次创建新实例:
    auth_bp = Blueprint('auth', __name__)
    app.register_blueprint(auth_bp)

Dead Ends

Common approaches that don't work:

  1. 60% fail

    尝试创建新蓝图但使用了相同名称。

  2. 80% fail

    在多个文件中导入并注册同一蓝图。