I'm trying to create complex routing for a get request that looks like this:
@app.route('/get-details?id=<int:id>&code=<int:code>', methods=['GET'])
@login_required
def get_details(id, code):
# Do something with code and id ....
And in my template I have a form that looks like this:
<form action="{{url_for('get_details')}}" method="get">
{{ form.hidden_tag() }}
{{ form.id() }}
{{ form.code() }}
<input type="submit">
</form>
But when I try to render my page I get this exception:
File "/home/sharon/dev/wiseart/credixdealer/app/templates/dashboard/form-device.html", line 113, in block "content"
<form action="{{url_for('get_details')}}" method="get">
File "/usr/local/lib/python2.7/dist-packages/flask/helpers.py", line 332, in url_for
return appctx.app.handle_url_build_error(error, endpoint, values)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1811, in handle_url_build_error
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/helpers.py", line 322, in url_for
force_external=external)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/routing.py", line 1758, in build
raise BuildError(endpoint, values, method, self)
BuildError: Could not build url for endpoint 'get_details'. Did you forget to specify values ['business_id', 'id']?
How can I specify in url_for that the parameters should be retrieved from the form itself?