Commit 97d8f037 by Tom Christie

Only set .action attribute in override_method if it already existed on the view

parent 01986fc8
......@@ -46,13 +46,16 @@ class override_method(object):
def __enter__(self):
self.view.request = clone_request(self.request, self.method)
if self.action is not None:
# For viewsets we also set the `.action` attribute.
action_map = getattr(self.view, '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
if self.action is not None:
self.view.action = self.action
class Empty(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment