#31724: django.urls.resolve ignores the FORCE_SCRIPT_NAME setting.
-------------------------------+--------------------------------------
Reporter: Pēteris Caune | Owner: nobody
Type: Bug | Status: closed
Component: Core (URLs) | Version: 3.0
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Comment (by Pēteris Caune):
Thanks for the extra detail, Florian!
Perhaps the documentation should mention that `reverse` will obey
`FORCE_SCRIPT_NAME` but `resolve` won't? They are both in the same module,
they are documented on the same page and they look like inverse operations
– I knew `reverse` uses `FORCE_SCRIPT_NAME` and that's why I assumed
`resolve` would as well.
My use case: I'm using `resolve` for whitelisting redirect URLs. In my
app, the login page can take a `?next=some-url` GET parameter, and after
the user logs in, they get redirected to `some-url`. I wanted to have a
whitelist of what redirect targets are allowed. So I'm passing `some-url`
to `resolve` and am looking if the `ResolverMatch.url_name` is in my
whitelist. Does this seem like a reasonable use case for `resolve`?
And I'm using `FORCE_SCRIPT_NAME` setting because indeed I need to
generate URLs from outside of a request context (management commands
sending emails with links in them).
--
Ticket URL: <https://code.djangoproject.com/ticket/31724#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.743426c90f7a55db90f2f92fe776fc3f%40djangoproject.com.