aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/request.py
diff options
context:
space:
mode:
authorAndrew Fong2014-08-16 15:05:46 -0700
committerAndrew Fong2014-08-16 15:05:46 -0700
commit5f63d31b002020148c526f2d5ec27f723a06f2e9 (patch)
tree9037ff7a1467176f50fc73b58b555306c77185f0 /rest_framework/request.py
parent38a0e3e6278db96660c89bfcb3e660704c068ff5 (diff)
downloaddjango-rest-framework-5f63d31b002020148c526f2d5ec27f723a06f2e9.tar.bz2
override_method should substitute action
A view's action is dependent on the request method. When overriding the method (e.g. to generate a form for a POST request on a GET call to the browseable API), the action should be updated as well. Otherwise, viewset functions may be in a weird limbo state where a 'list' action has a POST method.
Diffstat (limited to 'rest_framework/request.py')
-rw-r--r--rest_framework/request.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/rest_framework/request.py b/rest_framework/request.py
index 40467c03..1ea61586 100644
--- a/rest_framework/request.py
+++ b/rest_framework/request.py
@@ -42,12 +42,16 @@ class override_method(object):
self.view = view
self.request = request
self.method = method
+ self.action = getattr(view, 'action', None)
def __enter__(self):
self.view.request = clone_request(self.request, self.method)
+ action_map = getattr(self, 'action_map', {})
+ self.view.action = action_map.get(self.method.lower())
return self.view.request
def __exit__(self, *args, **kwarg):
+ self.view.action = self.action
self.view.request = self.request