mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Fix None values representation in childs of ListField, DictField. (#4118)
This commit is contained in:
parent
daccc2b8f3
commit
768ae26aa4
|
@ -1480,7 +1480,7 @@ class ListField(Field):
|
|||
"""
|
||||
List of object instances -> List of dicts of primitive datatypes.
|
||||
"""
|
||||
return [self.child.to_representation(item) for item in data]
|
||||
return [self.child.to_representation(item) if item is not None else None for item in data]
|
||||
|
||||
|
||||
class DictField(Field):
|
||||
|
@ -1527,7 +1527,7 @@ class DictField(Field):
|
|||
List of object instances -> List of dicts of primitive datatypes.
|
||||
"""
|
||||
return {
|
||||
six.text_type(key): self.child.to_representation(val)
|
||||
six.text_type(key): self.child.to_representation(val) if val is not None else None
|
||||
for key, val in value.items()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user