mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Change decorator attribute name to url_path per suggestions
This commit is contained in:
parent
6a095e9110
commit
92ebeaa040
|
@ -177,26 +177,26 @@ class SimpleRouter(BaseRouter):
|
||||||
# Dynamic detail routes (@detail_route decorator)
|
# Dynamic detail routes (@detail_route decorator)
|
||||||
for httpmethods, methodname in detail_routes:
|
for httpmethods, methodname in detail_routes:
|
||||||
method_kwargs = getattr(viewset, methodname).kwargs
|
method_kwargs = getattr(viewset, methodname).kwargs
|
||||||
custom_method_name = method_kwargs.pop("custom_method_name", None) or methodname
|
url_path = method_kwargs.pop("url_path", None) or methodname
|
||||||
initkwargs = route.initkwargs.copy()
|
initkwargs = route.initkwargs.copy()
|
||||||
initkwargs.update(method_kwargs)
|
initkwargs.update(method_kwargs)
|
||||||
ret.append(Route(
|
ret.append(Route(
|
||||||
url=replace_methodname(route.url, custom_method_name),
|
url=replace_methodname(route.url, url_path),
|
||||||
mapping=dict((httpmethod, methodname) for httpmethod in httpmethods),
|
mapping=dict((httpmethod, methodname) for httpmethod in httpmethods),
|
||||||
name=replace_methodname(route.name, custom_method_name),
|
name=replace_methodname(route.name, url_path),
|
||||||
initkwargs=initkwargs,
|
initkwargs=initkwargs,
|
||||||
))
|
))
|
||||||
elif isinstance(route, DynamicListRoute):
|
elif isinstance(route, DynamicListRoute):
|
||||||
# Dynamic list routes (@list_route decorator)
|
# Dynamic list routes (@list_route decorator)
|
||||||
for httpmethods, methodname in list_routes:
|
for httpmethods, methodname in list_routes:
|
||||||
method_kwargs = getattr(viewset, methodname).kwargs
|
method_kwargs = getattr(viewset, methodname).kwargs
|
||||||
custom_method_name = method_kwargs.pop("custom_method_name", None) or methodname
|
url_path = method_kwargs.pop("url_path", None) or methodname
|
||||||
initkwargs = route.initkwargs.copy()
|
initkwargs = route.initkwargs.copy()
|
||||||
initkwargs.update(method_kwargs)
|
initkwargs.update(method_kwargs)
|
||||||
ret.append(Route(
|
ret.append(Route(
|
||||||
url=replace_methodname(route.url, custom_method_name),
|
url=replace_methodname(route.url, url_path),
|
||||||
mapping=dict((httpmethod, methodname) for httpmethod in httpmethods),
|
mapping=dict((httpmethod, methodname) for httpmethod in httpmethods),
|
||||||
name=replace_methodname(route.name, custom_method_name),
|
name=replace_methodname(route.name, url_path),
|
||||||
initkwargs=initkwargs,
|
initkwargs=initkwargs,
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user