mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-08 06:14:47 +03:00
Allow multiple @detail_route and/or @list_route for the same URL but different HTTP methods.
This commit is contained in:
parent
970bfe16ec
commit
6e18ed7dc8
|
@ -166,20 +166,22 @@ class SimpleRouter(BaseRouter):
|
|||
list_routes.append((httpmethods, methodname))
|
||||
|
||||
def _get_dynamic_routes(route, dynamic_routes):
|
||||
ret = []
|
||||
routes_map = OrderedDict()
|
||||
for httpmethods, methodname in dynamic_routes:
|
||||
method_kwargs = getattr(viewset, methodname).kwargs
|
||||
initkwargs = route.initkwargs.copy()
|
||||
initkwargs.update(method_kwargs)
|
||||
url_path = initkwargs.pop("url_path", None) or methodname
|
||||
ret.append(Route(
|
||||
url=replace_methodname(route.url, url_path),
|
||||
mapping=dict((httpmethod, methodname) for httpmethod in httpmethods),
|
||||
name=replace_methodname(route.name, url_path),
|
||||
initkwargs=initkwargs,
|
||||
))
|
||||
url = replace_methodname(route.url, url_path)
|
||||
if url not in routes_map:
|
||||
routes_map[url] = {
|
||||
'mapping': {},
|
||||
'name': replace_methodname(route.name, url_path),
|
||||
'initkwargs': initkwargs
|
||||
}
|
||||
routes_map[url]['mapping'].update(dict((httpmethod, methodname) for httpmethod in httpmethods))
|
||||
|
||||
return ret
|
||||
return list(Route(url=url, **args) for url, args in routes_map.items())
|
||||
|
||||
ret = []
|
||||
for route in self.routes:
|
||||
|
|
Loading…
Reference in New Issue
Block a user