allow default values in writable serializer fields

This commit is contained in:
Craig de Stigter 2013-03-18 14:50:08 +13:00
parent c8416df0c4
commit d6d5b1d82a

View File

@ -360,7 +360,9 @@ class BaseSerializer(WritableField):
except KeyError:
if self.required:
raise ValidationError(self.error_messages['required'])
return
if self.default is None:
return
value = copy.deepcopy(self.default)
# Set the serializer object if it exists
obj = getattr(self.parent.object, field_name) if self.parent.object else None