Fix None values representation in childs of ListField, DictField. (#4118)

This commit is contained in:
KhasanovBI 2016-05-16 11:30:23 +03:00 committed by Tom Christie
parent daccc2b8f3
commit 768ae26aa4

View File

@ -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()
}