mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Tweak method ordering for better consistency
This commit is contained in:
parent
0e80a535fb
commit
06b28f66ed
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user