Remove unnecessary hasattr all and add comment for nested relationships

This commit is contained in:
J. Iván Alegre 2014-12-10 09:19:27 +01:00
parent 59470667db
commit 9161e5a927

View File

@ -517,7 +517,9 @@ class ListSerializer(BaseSerializer):
"""
List of object instances -> List of dicts of primitive datatypes.
"""
iterable = data.all() if (isinstance(data, models.Manager) and hasattr(data, 'all')) else data
# Dealing with nested relationships, data can be a Manager,
# so, first get a queryset from the Manager if needed
iterable = data.all() if isinstance(data, models.Manager) else data
return [
self.child.to_representation(item) for item in iterable
]