diff options
| author | Tom Christie | 2014-08-18 20:56:17 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-08-18 20:56:17 +0100 |
| commit | 97d8f037cc1292407eae965ceb4df34a52bd6161 (patch) | |
| tree | 8739381b175b4749708e500327c16c110baaeaba /rest_framework | |
| parent | 01986fc80eb1d07c11322991ddc6d4cfc105a6d9 (diff) | |
| download | django-rest-framework-97d8f037cc1292407eae965ceb4df34a52bd6161.tar.bz2 | |
Only set .action attribute in override_method if it already existed on the view
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/request.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/rest_framework/request.py b/rest_framework/request.py index 4f9345f3..d508f9b4 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -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): |
