I keek getting an error:
werkzeug.routing.BuildError: Could not build url for endpoint 'foo.bar, id=1'. Did you mean 'foo.bar' instead?
foobp= Blueprint('foo', __name__)
@foobp.route('/bar/<id>', , methods=['get', 'post'])
def bar(id):
id_var = id
form = SomeForm()
if form.validate_on_submit():
# do database stuff
return redirect(url_for('foo.bar, id={}'.format(id_var)))
# do some other stuff
return render_template('bar'html, form=form, ...)
I have tried dropping the 'foo.bar'
and doing just 'bar'
but that doesn't seem to work either.
What am I doing wrong?
Try this:
return redirect(url_for('foo.bar', id=id_var))
Also you have two commas in your route definition.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.