Skip to content

Commit

Permalink
Merge pull request #2331 from tomchristie/use-custom-list-serializer-…
Browse files Browse the repository at this point in the history
…for-pagination

Use custom ListSerializer for pagination if required.
  • Loading branch information
tomchristie committed Dec 20, 2014
2 parents ffb8d56 + 03c4eb1 commit e4c7c10
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rest_framework/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ def __init__(self, *args, **kwargs):
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'
)
Expand Down

0 comments on commit e4c7c10

Please sign in to comment.