mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 19:40:13 +03:00
Fix for serialisation of multiple objects (m2m)
This commit is contained in:
parent
da13a0e481
commit
53e7b9fafc
|
@ -899,7 +899,13 @@ 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)
|
for m2m_object in object_list:
|
||||||
|
for field in m2m_object.__dict__.keys():
|
||||||
|
print field
|
||||||
|
if not field == 'id':
|
||||||
|
attr = getattr(m2m_object, field)
|
||||||
|
setattr(m2m_object, field, m2m_object.__dict__[field])
|
||||||
|
m2m_object.save()
|
||||||
del(obj._m2m_data)
|
del(obj._m2m_data)
|
||||||
|
|
||||||
if getattr(obj, '_related_data', None):
|
if getattr(obj, '_related_data', None):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user