mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
Merge 929937693c
into 2621e03aa3
This commit is contained in:
commit
58eeec7982
|
@ -498,6 +498,13 @@ class Serializer(BaseSerializer):
|
||||||
# resolve the pk value.
|
# resolve the pk value.
|
||||||
check_for_none = attribute.pk if isinstance(attribute, PKOnlyObject) else attribute
|
check_for_none = attribute.pk if isinstance(attribute, PKOnlyObject) else attribute
|
||||||
if check_for_none is None:
|
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
|
ret[field.field_name] = None
|
||||||
else:
|
else:
|
||||||
ret[field.field_name] = field.to_representation(attribute)
|
ret[field.field_name] = field.to_representation(attribute)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user