[Django] #33423: Load urls from function in URLResolver

2 views
Skip to first unread message

Django

unread,
Jan 7, 2022, 10:59:27 AM1/7/22
to django-...@googlegroups.com
#33423: Load urls from function in URLResolver
---------------------------------------+------------------------
Reporter: William | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: 4.0
Severity: Normal | Keywords: urls
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+------------------------
Instead of immediately raising an error if the {{{urlpatterns}}} in the
loaded module is not a list, it would instead check if there is a
{{{get_urls}}} function in the module and call it. If there is no such
function or it returns something other then a list raise the error, if it
returns a list then use that instead of raising an error.

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

Django

unread,
Jan 7, 2022, 11:48:25 AM1/7/22
to django-...@googlegroups.com
#33423: Load urls from function in URLResolver
-----------------------------+--------------------------------------

Reporter: William | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: 4.0
Severity: Normal | Resolution:

Keywords: urls | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by William):

* has_patch: 0 => 1


Old description:

> Instead of immediately raising an error if the {{{urlpatterns}}} in the
> loaded module is not a list, it would instead check if there is a
> {{{get_urls}}} function in the module and call it. If there is no such
> function or it returns something other then a list raise the error, if it
> returns a list then use that instead of raising an error.

New description:

Instead of immediately raising an error if the {{{urlpatterns}}} in the
loaded module is not a list, it would instead check if there is a
{{{get_urls}}} function in the module and call it. If there is no such
function or it returns something other then a list raise the error, if it
returns a list then use that instead of raising an error.

[https://github.com/django/django/pull/15293 PR]

--

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

Django

unread,
Jan 7, 2022, 12:02:20 PM1/7/22
to django-...@googlegroups.com
#33423: Load urls from function in URLResolver
-----------------------------+--------------------------------------
Reporter: William | Owner: nobody
Type: New feature | Status: closed

Component: Core (URLs) | Version: 4.0
Severity: Normal | Resolution: wontfix

Keywords: urls | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => wontfix


Comment:

Thanks for this proposition, however I don't think it's common enough to
create URLs at runtime. As far as I'm aware, in other cases function
should not be necessary.

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]. Don't forget to explain your use case.

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

Reply all
Reply to author
Forward
0 new messages