aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/mixins.py
diff options
context:
space:
mode:
authorTom Christie2013-05-22 09:07:12 +0100
committerTom Christie2013-05-22 09:07:12 +0100
commit06b28f66edf0dafd5a93c031248975db372fa4af (patch)
tree6eb1c2f8f4ef06837ee58e69552af27fe62ec36f /rest_framework/mixins.py
parent0e80a535fb617ffb64f948f53cc1831249487f1a (diff)
downloaddjango-rest-framework-06b28f66edf0dafd5a93c031248975db372fa4af.tar.bz2
Tweak method ordering for better consistency
Diffstat (limited to 'rest_framework/mixins.py')
-rw-r--r--rest_framework/mixins.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py
index f3cd5868..f11def6d 100644
--- a/rest_framework/mixins.py
+++ b/rest_framework/mixins.py
@@ -110,16 +110,6 @@ class UpdateModelMixin(object):
"""
Update a model instance.
"""
- def get_object_or_none(self):
- 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'))
-
def update(self, request, *args, **kwargs):
partial = kwargs.pop('partial', False)
self.object = self.get_object_or_none()
@@ -148,6 +138,16 @@ class UpdateModelMixin(object):
kwargs['partial'] = True
return self.update(request, *args, **kwargs)
+ def get_object_or_none(self):
+ 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'))
+
def pre_save(self, obj):
"""
Set any attributes on the object that are implicit in the request.