@@ -99,6 +99,13 @@ def url_path_detail(self, request, *args, **kwargs):
99
99
kwarg = self .kwargs .get ('kwarg' , '' )
100
100
return Response ({'pk' : pk , 'kwarg' : kwarg })
101
101
102
+ @action (detail = True , url_path = 'detail/<int:kwarg>/detail/<int:param>' )
103
+ def url_path_detail_multiple_params (self , request , * args , ** kwargs ):
104
+ pk = self .kwargs .get ('pk' , '' )
105
+ kwarg = self .kwargs .get ('kwarg' , '' )
106
+ param = self .kwargs .get ('param' , '' )
107
+ return Response ({'pk' : pk , 'kwarg' : kwarg , 'param' : param })
108
+
102
109
103
110
notes_router = SimpleRouter ()
104
111
notes_router .register (r'notes' , NoteViewSet )
@@ -561,6 +568,18 @@ def test_detail_extra_action(self):
561
568
assert response .status_code == 200
562
569
assert json .loads (response .content .decode ()) == {'pk' : pk , 'kwarg' : kwarg }
563
570
571
+ def test_detail_extra_other_action (self ):
572
+ # this to assure that ambiguous patterns are interpreted correctly
573
+ # using the `path` converters this URL is recognized to match the pattern
574
+ # of `UrlPathViewSet.url_path_detail` when it should match
575
+ # `UrlPathViewSet.url_path_detail_multiple_params`
576
+ pk = '1'
577
+ kwarg = 1234
578
+ param = 2
579
+ response = self .client .get ('/path/1/detail/1234/detail/2/' )
580
+ assert response .status_code == 200
581
+ assert json .loads (response .content .decode ()) == {'pk' : pk , 'kwarg' : kwarg , 'param' : param }
582
+
564
583
def test_defaultrouter_root (self ):
565
584
response = self .client .get ('/default/' )
566
585
assert response .status_code == 200
0 commit comments