diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 9b729712c..9007788f8 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -284,6 +284,7 @@ class SimpleRouter(BaseRouter): initkwargs = route.initkwargs.copy() initkwargs.update({ 'basename': basename, + 'detail': route.detail, }) view = viewset.as_view(mapping, **initkwargs) diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py index 164347f93..9a85049bc 100644 --- a/rest_framework/viewsets.py +++ b/rest_framework/viewsets.py @@ -56,6 +56,9 @@ class ViewSetMixin(object): # eg. 'List' or 'Instance'. cls.suffix = None + # The detail initkwarg is reserved for introspecting the viewset type. + cls.detail = None + # Setting a basename allows a view to reverse its action urls. This # value is provided by the router through the initkwargs. cls.basename = None diff --git a/tests/test_routers.py b/tests/test_routers.py index 5a1cfe8f4..bc72e55d7 100644 --- a/tests/test_routers.py +++ b/tests/test_routers.py @@ -446,6 +446,12 @@ class TestViewInitkwargs(TestCase): assert initkwargs['suffix'] == 'List' + def test_detail(self): + match = resolve('/example/notes/') + initkwargs = match.func.initkwargs + + assert not initkwargs['detail'] + def test_basename(self): match = resolve('/example/notes/') initkwargs = match.func.initkwargs