class UpdateModelMixin

from rest_framework.mixins import UpdateModelMixin
Documentation Source code
    Update a model instance.

Ancestors (MRO)

  1. UpdateModelMixin

Methods used but not implemented in this class

  • get_object
  • get_serializer
Expand Collapse


def partial_update(self, request, *args, **kwargs): UpdateModelMixin

    def partial_update(self, request, *args, **kwargs):
        kwargs['partial'] = True
        return self.update(request, *args, **kwargs)

def perform_update(self, serializer): UpdateModelMixin

    def perform_update(self, serializer):

def update(self, request, *args, **kwargs): UpdateModelMixin

    def update(self, request, *args, **kwargs):
        partial = kwargs.pop('partial', False)
        instance = self.get_object()
        serializer = self.get_serializer(instance,, partial=partial)

        if getattr(instance, '_prefetched_objects_cache', None):
            # If 'prefetch_related' has been applied to a queryset, we need to
            # forcibly invalidate the prefetch cache on the instance.
            instance._prefetched_objects_cache = {}

        return Response(