[Django] #35244: URL resolution does not work when giving a function reference if it is listed in `urls` with `app_name`

9 views
Skip to first unread message

Django

unread,
Feb 21, 2024, 10:42:00 AM2/21/24
to django-...@googlegroups.com
#35244: URL resolution does not work when giving a function reference if it is
listed in `urls` with `app_name`
-------------------------------------+-------------------------------------
Reporter: Willem | Owner: nobody
Van Onsem |
Type: | Status: new
Uncategorized |
Component: Core | Version: 5.0
(URLs) | Keywords: urls, resolve,
Severity: Normal | reverse, resolution
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
First mentioned on StackOverflow with:
https://stackoverflow.com/questions/78035103/in-django-is-it-possible-to-
use-reverse-redirect-with-a-view-function-not-stri

This is because the `.reverse_dict` dictionary is not populated with view
functions, or at least not if there is an `app_name` around line 563 of
`resolvers.py`:
https://github.com/django/django/blob/6feaad9113fd38ba3970032d2b7856c77403e29e/django/urls/resolvers.py#L563-L567

A patch is quite simple: look in the `.reverse_dict` of the subpath, and
propagate the values to the upper level in case these are callable (see
patch).

But the question is of course if this approach is sound and complete.
--
Ticket URL: <https://code.djangoproject.com/ticket/35244>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 21, 2024, 10:43:11 AM2/21/24
to django-...@googlegroups.com
#35244: URL resolution does not work when giving a function reference if it is
listed in `urls` with `app_name`
-------------------------------------+-------------------------------------
Reporter: Willem Van Onsem | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (URLs) | Version: 5.0
Severity: Normal | Resolution:
Keywords: urls, resolve, | Triage Stage:
reverse, resolution | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Willem Van Onsem):

* Attachment "resolver_view_function.patch" added.
Reply all
Reply to author
Forward
0 new messages