Skip to content

add support for query parameters in Route.url_path_for #669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ricardogsilva
Copy link

This PR add support for query parameters when resolving a URL with request.url_for and friends

From the added tests:

assert (
    app.url_path_for("homepage", some_query_param="this") == "/?some_query_param=this")

assert (
    app.url_path_for("homepage", **{"funky[query_param]": "this"}) =="/?funky%5Bquery_param%5D=this")

I find this useful in the context of getting a reproducible URL when generating pagination links for my API.

fixes #560

@ricardogsilva
Copy link
Author

I'm retreating this PR since there is further activity on the issue page (#560) that suggests the starlette maintainers plan to implement this functionality as part of a deeper refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support to request.url_for for query parameters
1 participant