Opened 10 years ago

Closed 10 years ago

#11630 closed (duplicate)

reverse() cannot process kwargs distributed along nested url namespaces

Reported by: daybreaker Owned by: nobody
Component: Core (Other) Version: 1.1
Severity: Keywords: urlresolver reverse namespace
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Look at this, just a simple example:

>>> reverse('lab:bbs:view', kwargs={'board_id':1, 'article_id':1})

You might notice the named regex pattern in the above url, and...

>>> reverse('lab:bbs:view', kwargs={'board_id':1, 'article_id':1, 'url_key':'asdf'})
<class 'django.core.urlresolvers.NoReverseMatch'>: Reverse for 'view' with arguments '()' and keyword arguments '{'board_id': 1, 'article_id': 1, 'url_key': 'asdf'}' not found.

...gets the error! (And also emits error with url templatetag.)

It SHOULD understand the url_key keyword argument.

My url configurations is like this:

urlpatterns = patterns('',
    (ur'^lab/', include('myproject.lab.urls')),

# lab/
extra_urlpatterns = patterns('myproject.lab.views',
    url(ur'^bbs/', include('myproject.bbs.urls', namespace='bbs')),

urlpatterns = patterns('myproject.lab.views',
    (ur'^(?P<url_key>[-a-zA-Z0-9]+)/', include(extra_urlpatterns, namespace='lab')),

# bbs/
urlpatterns = patterns('myproject.bbs.views',
    url(ur'^(?P<board_id>\d+)/view/(?P<article_id>\d+)/$', 'view', name='view'),

Change History (1)

comment:1 Changed 10 years ago by Russell Keith-Magee

Resolution: duplicate
Status: newclosed

Duplicate of #11559.

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