diff options
| author | Tom Christie | 2013-08-23 05:34:00 -0700 |
|---|---|---|
| committer | Tom Christie | 2013-08-23 05:34:00 -0700 |
| commit | 110d54940451e19f54792e78bfaba8a75cfd04f4 (patch) | |
| tree | 10f4005fee21a1e78162b245684bb81145f7b882 /rest_framework/mixins.py | |
| parent | 95b2bf50fbb9b95facebb23812bbbb2e27a76035 (diff) | |
| parent | e677f3ee5c9435594ce58a3256a119c08bdc1e42 (diff) | |
| download | django-rest-framework-110d54940451e19f54792e78bfaba8a75cfd04f4.tar.bz2 | |
Merge pull request #1034 from KrzysiekJ/patch-create-fallback-removal
PATCH requests should not be able to create objects.
Diffstat (limited to 'rest_framework/mixins.py')
| -rw-r--r-- | rest_framework/mixins.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index f11def6d..59d64469 100644 --- a/rest_framework/mixins.py +++ b/rest_framework/mixins.py @@ -142,11 +142,14 @@ class UpdateModelMixin(object): try: return self.get_object() except Http404: - # If this is a PUT-as-create operation, we need to ensure that - # we have relevant permissions, as if this was a POST request. - # This will either raise a PermissionDenied exception, - # or simply return None - self.check_permissions(clone_request(self.request, 'POST')) + if self.request.method == 'PUT': + # For PUT-as-create operation, we need to ensure that we have + # relevant permissions, as if this was a POST request. This + # will either raise a PermissionDenied exception, or simply + # return None. + self.check_permissions(clone_request(self.request, 'POST')) + else: + raise def pre_save(self, obj): """ |
