aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Iván Alegre2014-12-10 09:19:27 +0100
committerJ. Iván Alegre2014-12-10 09:19:27 +0100
commit9161e5a9276b185375e9ab7ec188112f6fe49cf0 (patch)
treecbcc18f65f7e30979ffc571cbc5152d9a5d9bf7d
parent59470667db1b95eef63ff4308c1b41561438bb8e (diff)
downloaddjango-rest-framework-9161e5a9276b185375e9ab7ec188112f6fe49cf0.tar.bz2
Remove unnecessary hasattr all and add comment for nested relationships
-rw-r--r--rest_framework/serializers.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index 9857995a..e1711259 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -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
]