Skip to content

Instantly share code, notes, and snippets.

@Sanqui
Forked from mitsuhiko/helper.py
Created September 22, 2012 08:49
Show Gist options
  • Save Sanqui/3765578 to your computer and use it in GitHub Desktop.
Save Sanqui/3765578 to your computer and use it in GitHub Desktop.
url_for_here()
from flask import request, url_for
# Supports multiple query args with the same key.
def url_for_here(**changed_args):
args = request.args.to_dict(flat=False)
args.update(request.view_args)
args.update(changed_args)
return url_for(request.endpoint, **args)
app.jinja_env.globals['url_for_here'] = url_for_here
<a href="{{ url_for_here(page=42) }}">page 42</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment