Opened 12 years ago
Closed 12 years ago
#19406 closed Bug (needsinfo)
Lacking named groups in urlpatterns of admin causes NoReverseMatch
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
As described in http://stackoverflow.com/q/13609600/165603
urlresolvers.reverse('admin:cards_card_change', args=[92])
could get the URL successfully, however the following cannot
urlresolvers.reverse('admin:cards_card_change', kwargs={'object_id':92})
The lacking of named groups in urlpattern causes the inconsistent behavior
urlpatterns = patterns('', #... url(r'^(.+)/history/$', wrap(self.history_view), name='%s_%s_history' % info), url(r'^(.+)/delete/$', wrap(self.delete_view), name='%s_%s_delete' % info), url(r'^(.+)/$', wrap(self.change_view), name='%s_%s_change' % info), )
Both history_view
, delete_view
and change_view
accept object_id
, thus we could replace r'^(.+)...'
to r'^(?P<object_id>.+)...'
to fix the problem.
Note:
See TracTickets
for help on using tickets.
What do you mean with 'inconsistent behavior'? these three views have been documented as accepting positional arguments since 1.1. See the examples in the documentation sction you've linked from the StackOverfolw question: https://docs.djangoproject.com/en/1.1/ref/contrib/admin/#reversing-admin-urls . Please reopen if you can provide an actual use case because of which we'd need to change it now.