aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorTom Christie2015-01-05 16:20:15 +0000
committerTom Christie2015-01-05 16:20:15 +0000
commit26ac2656e5e0b3d01a67551910113a305d2a2820 (patch)
treed8a5ac68df0e75cdf68903f826b6aa055c86b7bf /rest_framework
parent6fd33ddea9e5b8f9e979e573a27873131846ea48 (diff)
downloaddjango-rest-framework-26ac2656e5e0b3d01a67551910113a305d2a2820.tar.bz2
Pass init arguments through to serializer from pagination serializer.
Closes #2355. Normally a serializer won't need these arguments on __init__, but if a user has customized __init__ they may expect them to be available.
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/pagination.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py
index f31e5fa4..9c8dda8f 100644
--- a/rest_framework/pagination.py
+++ b/rest_framework/pagination.py
@@ -37,16 +37,13 @@ class PreviousPageField(serializers.Field):
return replace_query_param(url, self.page_field, page)
-class DefaultObjectSerializer(serializers.ReadOnlyField):
+class DefaultObjectSerializer(serializers.Serializer):
"""
If no object serializer is specified, then this serializer will be applied
as the default.
"""
-
- 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)
+ def to_representation(self, value):
+ return value
class BasePaginationSerializer(serializers.Serializer):
@@ -74,10 +71,9 @@ class BasePaginationSerializer(serializers.Serializer):
list_serializer_class = serializers.ListSerializer
self.fields[results_field] = list_serializer_class(
- child=object_serializer(),
+ child=object_serializer(*args, **kwargs),
source='object_list'
)
- self.fields[results_field].bind(field_name=results_field, parent=self)
class PaginationSerializer(BasePaginationSerializer):