Use custom ListSerializer for pagination if one is specified on the serializer.

This commit is contained in:
Tom Christie 2014-12-20 16:32:07 +00:00
parent 80bacc5fb0
commit 03c4eb1130

View File

@ -68,7 +68,12 @@ class BasePaginationSerializer(serializers.Serializer):
except AttributeError:
object_serializer = DefaultObjectSerializer
self.fields[results_field] = serializers.ListSerializer(
try:
list_serializer_class = object_serializer.Meta.list_serializer_class
except AttributeError:
list_serializer_class = serializers.ListSerializer
self.fields[results_field] = list_serializer_class(
child=object_serializer(),
source='object_list'
)