return None values as None in ListSerializer.to_representation

This commit is contained in:
Shen Li 2024-04-18 00:18:32 -04:00
parent 9864c47018
commit 57d837c826

View File

@ -711,7 +711,7 @@ class ListSerializer(BaseSerializer):
iterable = data.all() if isinstance(data, models.manager.BaseManager) else data
return [
self.child.to_representation(item) for item in iterable
self.child.to_representation(item) if item is not None else None for item in iterable
]
def validate(self, attrs):