Opened 2 years ago

Closed 2 years ago

#27243 closed New feature (needsinfo)

Make reverse_dict.getlist work with fully qualified module names

Reported by: Etienne Robillard Owned by: nobody
Component: Core (URLs) Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The function _reverse_with_prefix in django/urls/resolvers.py doesn't handle fully qualified module names. This patch ensure that reverse() works in this case.

Attachments (1)

resolvers.diff (824 bytes) - added by Etienne Robillard 2 years ago.

Download all attachments as: .zip

Change History (6)

Changed 2 years ago by Etienne Robillard

Attachment: resolvers.diff added

comment:1 Changed 2 years ago by Etienne Robillard

comment:2 Changed 2 years ago by Tim Graham

Needs tests: set

Can you please summarize the discussion and explain what use case this solves? Tests are also needed.

comment:3 Changed 2 years ago by Etienne Robillard

I want to make Django 1.10 fully compatible with my urlpatterns configuration. I use a custom urlresolver module (notmm.utils.urlmap) to allow mapping url patterns to named views:

from notmm.utils.urlmap import RegexURLMap
urlpatterns = RegexURLMap()
urlpatterns.add_routes('foobar.views',  
 (r'^index.html$', 'index'),
)

add_routes() automatically create a fully qualified callback object to ensure the view function is a callable. However, Django doesn't handle fully qualified module names in reverse() without this patch.

comment:4 Changed 2 years ago by Tim Graham

I guess you might be running into problems because Django 1.10 removed support for string view arguments in url() (a25d3ce007b90a0516aed54fc1c5a16510a290e4 and/or 785cc71d5b3300e2702b0b2fc7316e58ca70b563). I'm not sure whether or not we can accommodate the use case, but as-is your patch crashes the test suite.

comment:5 Changed 2 years ago by Tim Graham

Resolution: needsinfo
Status: newclosed

Please reopen if you can add more details and provide a tested patch.

Note: See TracTickets for help on using tickets.
Back to Top