Commit ff1efcf6 by Yuri Prezument

If null or blank - don't save the nested object

parent 901d2b0e
...@@ -891,6 +891,7 @@ class ModelSerializer(Serializer): ...@@ -891,6 +891,7 @@ class ModelSerializer(Serializer):
# Nested relationships need to be saved before we can save the # Nested relationships need to be saved before we can save the
# parent instance. # parent instance.
for field_name, sub_object in obj._nested_forward_relations.items(): for field_name, sub_object in obj._nested_forward_relations.items():
if sub_object:
self.save_object(sub_object) self.save_object(sub_object)
setattr(obj, field_name, sub_object) setattr(obj, field_name, sub_object)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment