mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 03:50:11 +03:00
Add 'ViewSet.detail' initkwarg
This commit is contained in:
parent
034f8d0283
commit
fed7616013
|
@ -284,6 +284,7 @@ class SimpleRouter(BaseRouter):
|
|||
initkwargs = route.initkwargs.copy()
|
||||
initkwargs.update({
|
||||
'basename': basename,
|
||||
'detail': route.detail,
|
||||
})
|
||||
|
||||
view = viewset.as_view(mapping, **initkwargs)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user