mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
allow default values in writable serializer fields
This commit is contained in:
parent
c8416df0c4
commit
d6d5b1d82a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user