mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Take in care that input data in serializer can be a Manager
This commit is contained in:
parent
8d6b0b1f2d
commit
59470667db
|
@ -517,8 +517,9 @@ class ListSerializer(BaseSerializer):
|
||||||
"""
|
"""
|
||||||
List of object instances -> List of dicts of primitive datatypes.
|
List of object instances -> List of dicts of primitive datatypes.
|
||||||
"""
|
"""
|
||||||
|
iterable = data.all() if (isinstance(data, models.Manager) and hasattr(data, 'all')) else data
|
||||||
return [
|
return [
|
||||||
self.child.to_representation(item) for item in data
|
self.child.to_representation(item) for item in iterable
|
||||||
]
|
]
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user