Redirect with data parameter in flask Redirect with data parameter in flask flask flask

Redirect with data parameter in flask


You cannot just put a form object into a URL, no. A redirect() is a response, telling the browser to go load a different URL, the form object is not something you can easily cram into a URL path element.

If you don't need to see a different URL in the browser location bar, don't use a redirect but simply call a different function:

def details(form):    return render_template('details.html', form = form):@app.route('/poll', methods = ['GET', 'POST'])def poll():    form = PollForm()    if form.validate_on_submit():        return details(form)    return render_template('poll.html', form=form)

If you do need a different URL in the browser, then have the <form> element post to the /details route, not the /poll route.