python config_error ai_generated true

werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'login'. Did you mean 'register' instead?

ID: python/flask-redirect-endpoint-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-09-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

在 url_for() 或 redirect() 中使用了不存在的端点名称。

generic

中文

在 url_for() 或 redirect() 中使用了不存在的端点名称。

Workarounds

  1. 100% success
    @app.route('/login', endpoint='login')
    def login_view():
        pass
    # 然后在其他地方使用
    redirect(url_for('login'))

Dead Ends

Common approaches that don't work:

  1. 80% fail

    会破坏 Flask 的路由系统,且不灵活

  2. 70% fail

    会导致路由冲突,且不解决根本问题