Вход в Flask: невозможно правильно установить конечную точку - PullRequest
0 голосов
/ 06 ноября 2019

Вот конечная точка, я хочу, чтобы мой менеджер входа указывал на

@app.route('/login/<path:someVal>', methods=['GET', 'POST'])
def login(someVal='default'):
    form = LoginForm()
    if form.validate_on_submit():
        '''
        some application logic here
        '''
        return redirect(url_for('somePage.'+someVal))

    return render_template('login.html', form=form)

, а вот часть кода, в которой я определяю мой менеджер входа

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'

сейчас, когдая запускаю свое приложение, я получаю

werkzeug.routing.BuildError
BuildError: Could not build url for endpoint 'login'. Did you forget to specify values ['someVal']?

как мне правильно определить эту конечную точку для моего менеджера входа в систему?

Вот полная трассировка стека

File "/path/to//site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/path/to//site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/path/to//site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/path/to//site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/path/to//site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/path/to//site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/path/to//site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/path/to//site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/path/to//site-packages/flask_login/utils.py", line 260, in decorated_view
return current_app.login_manager.unauthorized()
File "/path/to//site-packages/flask_login/login_manager.py", line 175, in unauthorized
redirect_url = make_login_url(login_view, next_url=request.url)
File "/path/to//site-packages/flask_login/utils.py", line 112, in login_url
base = expand_login_view(login_view)
File "/path/to//site-packages/flask_login/utils.py", line 89, in expand_login_view
return url_for(login_view)
File "/path/to//site-packages/flask/helpers.py", line 356, in url_for
return appctx.app.handle_url_build_error(error, endpoint, values)
File "/path/to//site-packages/flask/app.py", line 2061, in handle_url_build_error
reraise(exc_type, exc_value, tb)
File "/path/to//site-packages/flask/helpers.py", line 345, in url_for
force_external=external)
File "/path/to//site-packages/werkzeug/routing.py", line 1776, in build
raise BuildError(endpoint, values, method, self)
BuildError: Could not build url for endpoint 'login'. Did you forget to specify values ['someVal']?
...