From 112b52f57e8f5a4a54e2b0c40f442ee63daf9709 Mon Sep 17 00:00:00 2001 From: Alex Burgel Date: Fri, 24 May 2013 18:28:47 -0400 Subject: Allow action decorator to handle multiple http methods --- rest_framework/routers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'rest_framework/routers.py') diff --git a/rest_framework/routers.py b/rest_framework/routers.py index dba104c3..6c5fd004 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -131,20 +131,20 @@ class SimpleRouter(BaseRouter): dynamic_routes = [] for methodname in dir(viewset): attr = getattr(viewset, methodname) - httpmethod = getattr(attr, 'bind_to_method', None) - if httpmethod: - dynamic_routes.append((httpmethod, methodname)) + httpmethods = getattr(attr, 'bind_to_methods', None) + if httpmethods: + dynamic_routes.append((httpmethods, methodname)) ret = [] for route in self.routes: if route.mapping == {'{httpmethod}': '{methodname}'}: # Dynamic routes (@link or @action decorator) - for httpmethod, methodname in dynamic_routes: + for httpmethods, methodname in dynamic_routes: initkwargs = route.initkwargs.copy() initkwargs.update(getattr(viewset, methodname).kwargs) ret.append(Route( url=replace_methodname(route.url, methodname), - mapping={httpmethod: methodname}, + mapping=dict((httpmethod, methodname) for httpmethod in httpmethods), name=replace_methodname(route.name, methodname), initkwargs=initkwargs, )) -- cgit v1.2.3