mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #9038 -- Correctly handle URL patterns with the same name (or view name),
declared independently and that differ only by argument signatures. Patch from Russell Keith-Magee. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9087 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6c7cf34d69
commit
15b0158e39
4 changed files with 45 additions and 19 deletions
|
@ -65,6 +65,17 @@ test_data = (
|
|||
('extra-places', '/e-places/10/', ['10'], {}),
|
||||
('extra-people', '/e-people/fred/', ['fred'], {}),
|
||||
('extra-people', '/e-people/fred/', [], {'name': 'fred'}),
|
||||
|
||||
# Regression for #9038
|
||||
# These views are resolved by method name. Each method is deployed twice -
|
||||
# once with an explicit argument, and once using the default value on
|
||||
# the method. This is potentially ambiguous, as you have to pick the
|
||||
# correct view for the arguments provided.
|
||||
('kwargs_view', '/arg_view/', [], {}),
|
||||
('kwargs_view', '/arg_view/10/', [], {'arg1':10}),
|
||||
('regressiontests.urlpatterns_reverse.views.absolute_kwargs_view', '/absolute_arg_view/', [], {}),
|
||||
('regressiontests.urlpatterns_reverse.views.absolute_kwargs_view', '/absolute_arg_view/10/', [], {'arg1':10}),
|
||||
|
||||
)
|
||||
|
||||
class URLPatternReverse(TestCase):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.conf.urls.defaults import *
|
||||
from views import empty_view
|
||||
from views import empty_view, absolute_kwargs_view
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^places/(\d+)/$', empty_view, name='places'),
|
||||
|
@ -45,4 +45,11 @@ urlpatterns = patterns('',
|
|||
|
||||
# This is non-reversible, but we shouldn't blow up when parsing it.
|
||||
url(r'^(?:foo|bar)(\w+)/$', empty_view, name="disjunction"),
|
||||
|
||||
# Regression views for #9038. See tests for more details
|
||||
url(r'arg_view/$', 'kwargs_view'),
|
||||
url(r'arg_view/(?P<arg1>\d+)/$', 'kwargs_view'),
|
||||
url(r'absolute_arg_view/(?P<arg1>\d+)/$', absolute_kwargs_view),
|
||||
url(r'absolute_arg_view/$', absolute_kwargs_view),
|
||||
|
||||
)
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
def empty_view(request, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def kwargs_view(request, arg1=1, arg2=2):
|
||||
pass
|
||||
|
||||
def absolute_kwargs_view(request, arg1=1, arg2=2):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue