From 9195ccb97f608a48e39a277705fb197fe8c0d50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Jaworski?= Date: Wed, 3 Sep 2014 16:52:41 +0200 Subject: [PATCH] Use explicit many=True for object_serializer instantiation in PaginationSerializer and add catch dummy 'many' kwarg on DefaultObjectSerializer --- rest_framework/pagination.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index d51ea929b..9dce05b11 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -43,8 +43,9 @@ class DefaultObjectSerializer(serializers.Field): as the default. """ - def __init__(self, source=None, context=None): - # Note: Swallow context kwarg - only required for eg. ModelSerializer. + def __init__(self, source=None, many=None, context=None): + # Note: Swallow context and many kwargs - only required for + # eg. ModelSerializer. super(DefaultObjectSerializer, self).__init__(source=source) @@ -82,7 +83,10 @@ class BasePaginationSerializer(serializers.Serializer): else: context_kwarg = {} - self.fields[results_field] = object_serializer(source='object_list', **context_kwarg) + print object_serializer + self.fields[results_field] = object_serializer(source='object_list', + many=True, + **context_kwarg) class PaginationSerializer(BasePaginationSerializer):