Parametrizable viewset custom views reverse name

This commit is contained in:
lzac 2017-01-17 09:55:37 +01:00
parent 06a5bcc88e
commit b4e70dfdbf

View File

@ -179,10 +179,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
url_name = initkwargs.pop("url_name", None) or url_path
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},
name=replace_methodname(route.name, url_path), name=replace_methodname(route.name, url_name),
initkwargs=initkwargs, initkwargs=initkwargs,
)) ))