mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-25 11:33:43 +03:00
If null or blank - don't save the nested object
This commit is contained in:
parent
901d2b0eb8
commit
ff1efcf60f
|
@ -891,6 +891,7 @@ class ModelSerializer(Serializer):
|
|||
# Nested relationships need to be saved before we can save the
|
||||
# parent instance.
|
||||
for field_name, sub_object in obj._nested_forward_relations.items():
|
||||
if sub_object:
|
||||
self.save_object(sub_object)
|
||||
setattr(obj, field_name, sub_object)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user