Opened 8 years ago

Closed 8 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 8 years ago.

Download all attachments as: .zip

Change History (6)

by Etienne Robillard, 8 years ago

Attachment: resolvers.diff added

comment:1 by Etienne Robillard, 8 years ago

comment:2 by Tim Graham, 8 years ago

Needs tests: set

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

comment:3 by Etienne Robillard, 8 years ago

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 by Tim Graham, 8 years ago

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 by Tim Graham, 8 years ago

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