reverted condition

This commit is contained in:
Krystof Rehacek 2019-06-20 11:46:05 +02:00
parent 9942453e31
commit 064f1e9a14

View File

@ -975,7 +975,9 @@ class ModelSerializer(Serializer):
# have an instance pk for the relationships to be associated with. # have an instance pk for the relationships to be associated with.
m2m_fields = [] m2m_fields = []
for attr, value in validated_data.items(): for attr, value in validated_data.items():
if attr not in info.relations or not info.relations[attr].to_many: if attr in info.relations and info.relations[attr].to_many:
m2m_fields.append((attr, value))
else:
setattr(instance, attr, value) setattr(instance, attr, value)
else: else:
m2m_fields.append((attr, value)) m2m_fields.append((attr, value))