#13154: Make reverse() match the behavior of resolve()
----------------------------+-----------------------------------------------
Reporter: patrys | Owner: nobody
Status: new | Milestone:
Component: Core framework | Version: SVN
Keywords: | Stage: Unreviewed
Has_patch: 1 |
----------------------------+-----------------------------------------------
Consider the following `urls.py`:
{{{
urlpatterns = patterns('',
(r'^faq/$', 'django.views.generic.simple.direct_to_template',
{'template': 'faq.html'}, 'faq'),
(r'^tos/$', 'django.views.generic.simple.direct_to_template',
{'template': 'tos.html'}, 'tos'),
)
}}}
When passed to `resolve()`, `/faq/` will yield:
{{{
>>> resolve('/faq/')
(<function direct_to_template at 0x8b2679c>, (), {'template': 'faq.html'})
}}}
However this will raise an exception:
{{{
>>> reverse('django.views.generic.simple.direct_to_template',
kwargs={'template': 'faq.html'})
NoReverseMatch: Reverse for
'django.views.generic.simple.direct_to_template' with arguments '()' and
keyword arguments '{'template': 'faq.html'}' not found.
}}}
The attached patch makes `reverse()` behave more intuitively and return a
match when both the key and value match the default kwargs.
{{{
>>> reverse('django.views.generic.simple.direct_to_template',
kwargs={'template': 'faq.html'})
'/faq/'
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/13154>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.