aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/mixins.py
diff options
context:
space:
mode:
authorKrzysztof Jurewicz2013-08-13 13:26:30 +0200
committerKrzysztof Jurewicz2013-08-13 13:26:30 +0200
commite677f3ee5c9435594ce58a3256a119c08bdc1e42 (patch)
treecbcefce88423f61ea6f27b7bb69a707e70c15d6a /rest_framework/mixins.py
parent999056cde1c6355d5ca036f109b35b41cb9d47cc (diff)
downloaddjango-rest-framework-e677f3ee5c9435594ce58a3256a119c08bdc1e42.tar.bz2
PATCH requests should not be able to create objects.
Diffstat (limited to 'rest_framework/mixins.py')
-rw-r--r--rest_framework/mixins.py13
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):
"""