mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Only set .action attribute in override_method if it already existed on the view
This commit is contained in:
parent
01986fc80e
commit
97d8f037cc
|
@ -46,13 +46,16 @@ class override_method(object):
|
|||
|
||||
def __enter__(self):
|
||||
self.view.request = clone_request(self.request, self.method)
|
||||
action_map = getattr(self.view, 'action_map', {})
|
||||
self.view.action = action_map.get(self.method.lower())
|
||||
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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user