Redirect to a URL which contains a 'variable part' in Flask (Python) Redirect to a URL which contains a 'variable part' in Flask (Python) flask flask

Redirect to a URL which contains a 'variable part' in Flask (Python)


You will want to create your URL with url_for by giving it the name of your URL, the keyword arg, and value for your URL parameter in the following manner:

return redirect(url_for('dashboard', username='foo'))


The point '.dashboard' is important

return redirect(url_for('.dashboard', username='foo'))