Skip to content

Commit e4c7c10

Browse files
committed
Merge pull request #2331 from tomchristie/use-custom-list-serializer-for-pagination
Use custom ListSerializer for pagination if required.
2 parents ffb8d56 + 03c4eb1 commit e4c7c10

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rest_framework/pagination.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ def __init__(self, *args, **kwargs):
6868
except AttributeError:
6969
object_serializer = DefaultObjectSerializer
7070

71-
self.fields[results_field] = serializers.ListSerializer(
71+
try:
72+
list_serializer_class = object_serializer.Meta.list_serializer_class
73+
except AttributeError:
74+
list_serializer_class = serializers.ListSerializer
75+
76+
self.fields[results_field] = list_serializer_class(
7277
child=object_serializer(),
7378
source='object_list'
7479
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy