mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 19:40:13 +03:00
Merge 929937693c
into 2621e03aa3
This commit is contained in:
commit
58eeec7982
|
@ -498,6 +498,13 @@ class Serializer(BaseSerializer):
|
|||
# resolve the pk value.
|
||||
check_for_none = attribute.pk if isinstance(attribute, PKOnlyObject) else attribute
|
||||
if check_for_none is None:
|
||||
if not field.allow_null:
|
||||
try:
|
||||
ret[field.field_name] = field.get_default()
|
||||
except SkipField:
|
||||
pass
|
||||
else:
|
||||
continue
|
||||
ret[field.field_name] = None
|
||||
else:
|
||||
ret[field.field_name] = field.to_representation(attribute)
|
||||
|
|
Loading…
Reference in New Issue
Block a user