-
-
Save Sanqui/3765578 to your computer and use it in GitHub Desktop.
url_for_here()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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