Invalidate any existing prefetch cache on PUT requests.

This commit is contained in:
Tom Christie 2016-11-10 15:41:36 +00:00
parent 388cf7622c
commit 384f3a0240

View File

@ -71,9 +71,8 @@ class UpdateModelMixin(object):
if getattr(instance, '_prefetched_objects_cache', None): if getattr(instance, '_prefetched_objects_cache', None):
# If 'prefetch_related' has been applied to a queryset, we need to # If 'prefetch_related' has been applied to a queryset, we need to
# refresh the instance from the database. # forcibly invalidate the prefetch cache on the instance.
instance = self.get_object() instance._prefetched_objects_cache = {}
serializer = self.get_serializer(instance)
return Response(serializer.data) return Response(serializer.data)