mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Merge pull request #1763 from fongandrew/patch-1
override_method should substitute action
This commit is contained in:
commit
01986fc80e
|
@ -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.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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user