mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 04:20:12 +03:00
Router sets 'basename' on ViewSet
This commit is contained in:
parent
905a5579df
commit
a80de2e108
|
@ -278,7 +278,12 @@ class SimpleRouter(BaseRouter):
|
|||
if not prefix and regex[:2] == '^/':
|
||||
regex = '^' + regex[2:]
|
||||
|
||||
view = viewset.as_view(mapping, **route.initkwargs)
|
||||
initkwargs = route.initkwargs.copy()
|
||||
initkwargs.update({
|
||||
'basename': basename,
|
||||
})
|
||||
|
||||
view = viewset.as_view(mapping, **initkwargs)
|
||||
name = route.name.format(basename=basename)
|
||||
ret.append(url(regex, view, name=name))
|
||||
|
||||
|
|
|
@ -46,10 +46,14 @@ class ViewSetMixin(object):
|
|||
instantiated view, we need to totally reimplement `.as_view`,
|
||||
and slightly modify the view function that is created and returned.
|
||||
"""
|
||||
# The suffix initkwarg is reserved for identifying the viewset type
|
||||
# The suffix initkwarg is reserved for displaying the viewset type.
|
||||
# eg. 'List' or 'Instance'.
|
||||
cls.suffix = 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
|
||||
|
||||
# actions must not be empty
|
||||
if not actions:
|
||||
raise TypeError("The `actions` argument must be provided when "
|
||||
|
|
Loading…
Reference in New Issue
Block a user