Replies: 2 comments 2 replies
-
Maybe it makes sense to add url = request.url_for('login') # https://example.com/login
url = request.build_url_for('login', scheme='http', hostname='anotherexample.com', port=8080, fragment='tab-2', query_params={"key": "value"}) # http://anotherexample.com:8080/login?key=value#tab-2
def build_url_for(path: str, path_params: dict, query_params:dict, scheme: str, port:int, fragment:str) IMO, it is a simple change that adds a big value. |
Beta Was this translation helpful? Give feedback.
-
I hope we can revise this.
I would really really like that! I've always been really annoyed by Wordpress by default having a schema and domain baked in everywhere, and I come from a mostly Django world where relative urls are the default, and for me seem to be so much simpler. The linked case of https vs http is one. Working locally with a port number in the URL that get's dropped is another. If possible, I would like to be able to set a default on the App level for this, as a kwarg as proposed above still means that different locations can have different outcomes depending on how one implements it. Would that be a solution? I might be able to create a PR. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice if the url_for command allowed for generating relative URLs since that is the function available in other areas, like Jinja templates. It would be easy to do. The current url_for method is:
But if modified to:
The default behavior wouldn't change and there would be a way to call it an get a relative "/home/" style url. This is handy when behind some proxies, load balancers, etc.
Beta Was this translation helpful? Give feedback.
All reactions