mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 22:04:48 +03:00
Add support for name parameter to route decorators
If a url_path with parameters is specified in a route decorator, the view name includes the parameters. Using the name parameter, the view name can be overridden.
This commit is contained in:
parent
f7917928c0
commit
b067aea79f
|
@ -172,10 +172,11 @@ class SimpleRouter(BaseRouter):
|
||||||
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
|
||||||
|
name = replace_methodname(route.name, initkwargs.pop("name", url_path))
|
||||||
ret.append(Route(
|
ret.append(Route(
|
||||||
url=replace_methodname(route.url, url_path),
|
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, url_path),
|
name=name,
|
||||||
initkwargs=initkwargs,
|
initkwargs=initkwargs,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user