refresh prefecth cache after saving data

This commit is contained in:
Olesya Borzdyko 2014-08-13 11:05:34 +04:00
parent 5d674927b8
commit b7a03d56d9

View File

@ -1014,6 +1014,9 @@ class ModelSerializer(Serializer):
if getattr(obj, '_m2m_data', None): if getattr(obj, '_m2m_data', None):
for accessor_name, object_list in obj._m2m_data.items(): for accessor_name, object_list in obj._m2m_data.items():
setattr(obj, accessor_name, object_list) setattr(obj, accessor_name, object_list)
if hasattr(obj, '_prefetched_objects_cache')\
and accessor_name in obj._prefetched_objects_cache:
obj._prefetched_objects_cache[accessor_name] = object_list
del(obj._m2m_data) del(obj._m2m_data)
if getattr(obj, '_related_data', None): if getattr(obj, '_related_data', None):