From 5023b66c917a26157581a2efe34bb1de63f74941 Mon Sep 17 00:00:00 2001 From: playma Date: Fri, 28 Jul 2023 10:32:40 +0800 Subject: [PATCH] fix: save pass through values --- drf_writable_nested/mixins.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drf_writable_nested/mixins.py b/drf_writable_nested/mixins.py index f40dd48..091fe74 100644 --- a/drf_writable_nested/mixins.py +++ b/drf_writable_nested/mixins.py @@ -29,27 +29,27 @@ def _extract_relations(self, validated_data): if isinstance(field, serializers.ListSerializer) and \ isinstance(field.child, serializers.ModelSerializer): - if field.source not in validated_data: + if field_name not in validated_data: # Skip field if field is not required continue - validated_data.pop(field.source) + validated_data.pop(field_name) reverse_relations[field_name] = ( - related_field, field.child, field.source) + related_field, field.child, field_name) if isinstance(field, serializers.ModelSerializer): - if field.source not in validated_data: + if field_name not in validated_data: # Skip field if field is not required continue - if validated_data.get(field.source) is None: + if validated_data.get(field_name) is None: if direct: # Don't process null value for direct relations # Native create/update processes these values continue - validated_data.pop(field.source) + validated_data.pop(field_name) # Reversed one-to-one looks like direct foreign keys but they # are reverse relations if direct: