pythonflask-login

Flask login to a custom page


By Default when using flask login it expects a path /login. I am trying to use another page /test/login but it is not working and giving error. Here is the required code snippet. Please let me know what I am doing wrong here

login_manager.login_view = "test/login"

@app.route('/test/login')
def login():
    print("CONTEXT ===> " + context_path)
    return render_template('login.html')

Error I am getting

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

Solution

  • Aren't you missing a "/" in your login_manager.login_view object?