#13052 closed (duplicate)
reverse() does not resolve correctly using namespaces in some cases
Reported by: | Owned by: | Florian Apolloner | |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Keywords: | ||
Cc: | Florian Apolloner | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When reversing a set of included urls with a url prefix which contains a parameter, the resolver will treat the url chunk before the include as a prefix and not process it.
from django.conf.urls.defaults import * app1 = (patterns('', url(r'^edit/(?P<object_id>\d+)/$', 'view', name='view'), url(r'^list/$', 'view', name='list'), ), 'myapp', 'theinstance1') app2 = (patterns('', url(r'^edit/(?P<object_id>\d+)/$', 'view', name='view'), url(r'^list/$', 'view', name='list'), ), 'myapp', 'theinstance2') urlpatterns = patterns('views', url(r'^site/$', 'view', name='view'), url(r'^site/(?P<site_id>\d+)/pages/', include(app1)), url(r'^site/', include(app2)), ) >>> from django.core.urlresolvers import reverse >>> reverse('view') '/site/' >>> reverse('view', current_app='theinstance1') '/site/' >>> reverse('myapp:view', current_app='theinstance1') '/site/(?P%3Csite_id%3E%5Cd+)/pages/list/' >>> reverse('myapp:list', current_app='theinstance1') '/site/(?P%3Csite_id%3E%5Cd+)/pages/list/'
Change History (3)
comment:1 by , 15 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Note:
See TracTickets
for help on using tickets.
The problem starts here: http://code.djangoproject.com/browser/django/trunk/django/core/urlresolvers.py#L345 The extra part is just added to prefix, but it can contain parts which need to be reversed.