Code

Opened 5 years ago

Closed 5 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: UI/UX:

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'),
    ...
)

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #11559.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.