from rest_framework.response import Response


class PartialUpdateModelMixin(object):
    """
    Update a model instance.
    Only allow PATCH, no PUT
    """
    def perform_update(self, serializer):
        serializer.save()

    def partial_update(self, request, *args, **kwargs):
        partial = True
        instance = self.get_object()
        serializer = self.get_serializer(instance, data=request.data, partial=partial)
        serializer.is_valid(raise_exception=True)
        self.perform_update(serializer)

        if getattr(instance, '_prefetched_objects_cache', None):
            # If 'prefetch_related' has been applied to a queryset, we need to
            # refresh the instance from the database.
            instance = self.get_object()
            serializer = self.get_serializer(instance)

        return Response(serializer.data)

@@ -519,304 +519,8 @@
 er)%0A
-%0A        if getattr(instance, '_prefetched_objects_cache', None):%0A            # If 'prefetch_related' has been applied to a queryset, we need to%0A            # refresh the instance from the database.%0A            instance = self.get_object()%0A            serializer = self.get_serializer(instance)%0A%0A
     

Remove unused prefetched_query optimization