Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#13052 closed (duplicate)

reverse() does not resolve correctly using namespaces in some cases

Reported by: trey@… Owned by: apollo13
Component: Uncategorized Version: master
Severity: Keywords:
Cc: apollo13 Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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')
>>> reverse('view', current_app='theinstance1')
>>> reverse('myapp:view', current_app='theinstance1')
>>> reverse('myapp:list', current_app='theinstance1')

Change History (3)

comment:1 Changed 6 years ago by apollo13

  • Cc apollo13 added
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to apollo13
  • Patch needs improvement unset
  • Status changed from new to assigned

The problem starts here: The extra part is just added to prefix, but it can contain parts which need to be reversed.

comment:2 Changed 6 years ago by russellm

  • Resolution set to duplicate
  • Status changed from assigned to closed

Duplicate of #11559

comment:3 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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