mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 13:00:12 +03:00
Merge 1c7ca24c02
into 56f0138bb9
This commit is contained in:
commit
001c16dda0
|
@ -178,7 +178,7 @@ class SimpleRouter(BaseRouter):
|
||||||
method_kwargs = getattr(viewset, methodname).kwargs
|
method_kwargs = getattr(viewset, methodname).kwargs
|
||||||
initkwargs = route.initkwargs.copy()
|
initkwargs = route.initkwargs.copy()
|
||||||
initkwargs.update(method_kwargs)
|
initkwargs.update(method_kwargs)
|
||||||
url_path = initkwargs.pop("url_path", None) or methodname
|
url_path = initkwargs.pop('url_path', None) or methodname
|
||||||
ret.append(Route(
|
ret.append(Route(
|
||||||
url=replace_methodname(route.url, url_path),
|
url=replace_methodname(route.url, url_path),
|
||||||
mapping={httpmethod: methodname for httpmethod in httpmethods},
|
mapping={httpmethod: methodname for httpmethod in httpmethods},
|
||||||
|
@ -269,6 +269,11 @@ class SimpleRouter(BaseRouter):
|
||||||
regex = '^' + regex[2:]
|
regex = '^' + regex[2:]
|
||||||
|
|
||||||
view = viewset.as_view(mapping, **route.initkwargs)
|
view = viewset.as_view(mapping, **route.initkwargs)
|
||||||
|
|
||||||
|
# Allow dynamic routes to set `serializer_class` kwarg
|
||||||
|
if isinstance(route, (DynamicDetailRoute, DynamicListRoute)):
|
||||||
|
view.serializer_class = route.initkwargs.pop('serializer_class', None)
|
||||||
|
|
||||||
name = route.name.format(basename=basename)
|
name = route.name.format(basename=basename)
|
||||||
ret.append(url(regex, view, name=name))
|
ret.append(url(regex, view, name=name))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user