[Django] #34461: Constructing urls outside the request cycle

6 views
Skip to first unread message

Django

unread,
Apr 5, 2023, 1:27:57 PM4/5/23
to django-...@googlegroups.com
#34461: Constructing urls outside the request cycle
-----------------------------------------+------------------------
Reporter: Sarah Boyce | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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 to `https://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 relative `STATIC_URL` and
append it to `BASE_URL`. This way there would be just one setting that
requires changing and many projects hopefully would make that configurable
via env vars etc.

--
Ticket URL: <https://code.djangoproject.com/ticket/34461>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 6, 2023, 1:14:26 AM4/6/23
to django-...@googlegroups.com
#34461: Constructing urls outside the request cycle
------------------------------+--------------------------------------

Reporter: Sarah Boyce | Owner: nobody
Type: New feature | Status: closed
Component: Core (Other) | Version: dev
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* cc: Florian Apolloner, David Sanders, Stewart Adam (added)
* resolution: => wontfix
* status: new => closed
* component: Uncategorized => Core (Other)


Comment:

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
[https://docs.djangoproject.com/en/stable/internals/contributing/bugs-and-
features/#requesting-features follow the guidelines with regards to
requesting features].

--
Ticket URL: <https://code.djangoproject.com/ticket/34461#comment:1>

Django

unread,
Apr 6, 2023, 3:15:56 AM4/6/23
to django-...@googlegroups.com
#34461: Constructing urls outside the request cycle
------------------------------+--------------------------------------
Reporter: Sarah Boyce | Owner: nobody
Type: New feature | Status: closed
Component: Core (Other) | Version: dev
Severity: Normal | Resolution: wontfix
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 Sarah Boyce):

Sorry 👍 moved to here: https://groups.google.com/g/django-
developers/c/YzRj7OXpLkk

--
Ticket URL: <https://code.djangoproject.com/ticket/34461#comment:2>

Reply all
Reply to author
Forward
0 new messages