mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-13 09:42:27 +03:00
Fix One field that is required=False, allow_null=True and not provided. to_representation should not explicitly set it to None
This commit is contained in:
parent
ccfe0a9637
commit
b0ca35ea55
|
@ -450,10 +450,10 @@ class Field:
|
||||||
except (KeyError, AttributeError) as exc:
|
except (KeyError, AttributeError) as exc:
|
||||||
if self.default is not empty:
|
if self.default is not empty:
|
||||||
return self.get_default()
|
return self.get_default()
|
||||||
if self.allow_null:
|
|
||||||
return None
|
|
||||||
if not self.required:
|
if not self.required:
|
||||||
raise SkipField()
|
raise SkipField()
|
||||||
|
if self.allow_null:
|
||||||
|
return None
|
||||||
msg = (
|
msg = (
|
||||||
'Got {exc_type} when attempting to get a value for field '
|
'Got {exc_type} when attempting to get a value for field '
|
||||||
'`{field}` on serializer `{serializer}`.\nThe serializer '
|
'`{field}` on serializer `{serializer}`.\nThe serializer '
|
||||||
|
|
Loading…
Reference in New Issue
Block a user