Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix None values representation in childs of ListField, DictField.
  • Loading branch information
khasanovbi committed May 14, 2016
commit b73da53ad40ff090f9d967f266cb6261c5b7dcdb
4 changes: 2 additions & 2 deletions rest_framework/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ def to_representation(self, data):
"""
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):
Expand Down Expand Up @@ -1527,7 +1527,7 @@ def to_representation(self, value):
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()
}

Expand Down