From 064f1e9a146e323f6c6e7c252243ac4702827a38 Mon Sep 17 00:00:00 2001 From: Krystof Rehacek Date: Thu, 20 Jun 2019 11:46:05 +0200 Subject: [PATCH] reverted condition --- rest_framework/serializers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index cccc17d2b..ae2e8fcc5 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -975,7 +975,9 @@ class ModelSerializer(Serializer): # have an instance pk for the relationships to be associated with. m2m_fields = [] 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) else: m2m_fields.append((attr, value))