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

This commit is contained in:
Yuri Prezument 2013-08-12 18:08:23 +03:00
parent 901d2b0eb8
commit ff1efcf60f

View File

@ -891,7 +891,8 @@ 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():
self.save_object(sub_object)
if sub_object:
self.save_object(sub_object)
setattr(obj, field_name, sub_object)
obj.save(**kwargs)