Opened 15 years ago

Closed 15 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

Description

Look at this, just a simple example:

>>> reverse('lab:bbs:view', kwargs={'board_id':1, 'article_id':1})
'/lab/(?P%3Curl_key%3E[-a-zA-Z0-9]+)/bbs/1/view/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:

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

# lab/urls.py
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/urls.py
urlpatterns = patterns('myproject.bbs.views',
    url(ur'^(?P<board_id>\d+)/view/(?P<article_id>\d+)/$', 'view', name='view'),
    ...
)

Change History (1)

comment:1 by Russell Keith-Magee, 15 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #11559.

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