Open
Description
Code of Conduct
- I agree to follow Django's Code of Conduct
Feature Description
We have migrated to 5.2 and loved the query
param in reverse()
. Thanks for adding this feature.
We recently encountered a limitation with this feature preventing us from using "unescaped" characters in the URL. For example in Stripe checkout (see https://docs.stripe.com/payments/checkout/custom-success-page?locale=en-GB), we need curly braces in the URL but this is being url-encoded in reverse()
.
Problem
Internally, reverse()
uses urllib.parse.urlencode()
as described in the documentation. The current implementation is not allowing "unescaped" characters like curly braces.
>>> urllib.parse.urlencode(query={"session_id": "{CHECKOUT_SESSION_ID}"})
'session_id=%7BCHECKOUT_SESSION_ID%7D'
What we want (as Stripe's doc says) is to have unescaped curly braces. This can be obtained in urlencode
with safe
param as:
>>> urllib.parse.urlencode(query={"session_id": "{CHECKOUT_SESSION_ID}"}, safe="{}")
'session_id={CHECKOUT_SESSION_ID}'
Request or proposal
request
Additional Details
No response
Implementation Suggestions
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Idea