#34461 closed New feature (wontfix)
Constructing urls outside the request cycle
Reported by: | Sarah Boyce | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Florian Apolloner, David Sanders, Stewart Adam | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There is a need to have some kind of URL outside the request cycle (such as sending emails which need to create a link).
For constructing a correct MEDIA_URL
/ STATIC_URL
we wanted to use the script prefix to allow for more dynamic changes (ie allow a user to move to a subpath without having to change multiple variables). In the request cycle you can use get_script_prefix()
for this but outside the request cycle this isn't currently very achievable (see related tickets #34028 #16734).
There is a current proposal from Florian Apolloner
I am really starting to lean towards introducing a setting (yes!) called
BASE_URL
that can be set tohttps://mysite.com/subpath
. This would allow for a) generating URLs outside a request context and b) allow us to mostly ignore script prefix. We could also use a relativeSTATIC_URL
and append it toBASE_URL
. This way there would be just one setting that requires changing and many projects hopefully would make that configurable via env vars etc.
Change History (2)
comment:1 by , 21 months ago
Cc: | added |
---|---|
Component: | Uncategorized → Core (Other) |
Resolution: | → wontfix |
Status: | new → closed |
comment:2 by , 21 months ago
Sorry 👍 moved to here: https://groups.google.com/g/django-developers/c/YzRj7OXpLkk
Thanks for the ticket. Creating a new setting is always controversial (we already have many of them) so please first start a discussion on the DevelopersMailingList, where you'll reach a wider audience and see what other think, and follow the guidelines with regards to requesting features.