mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
check for isinstance Page, prevents alt pagination
when using DEFAULT_PAGINATION_SERIALIZER_CLASS and a custom paginator_class BaseSerializer's checking for isinstance Page doesn't work. the custom paginator_class has it's own Page that doesn't inherit from django's base Page and thus its __iter__ method causes many=True, and iterating over the page and trying to serialize the objects through DEFAULT_PAGINATION_SERIALIZER_CLASS.
This commit is contained in:
parent
c3aeb16557
commit
18d8f818e0
|
@ -520,7 +520,7 @@ class BaseSerializer(WritableField):
|
||||||
if self.many is not None:
|
if self.many is not None:
|
||||||
many = self.many
|
many = self.many
|
||||||
else:
|
else:
|
||||||
many = hasattr(obj, '__iter__') and not isinstance(obj, (Page, dict))
|
many = hasattr(obj, '__iter__') and not (isinstance(obj, dict) or hasattr(obj, 'next_page_number'))
|
||||||
if many:
|
if many:
|
||||||
warnings.warn('Implict list/queryset serialization is deprecated. '
|
warnings.warn('Implict list/queryset serialization is deprecated. '
|
||||||
'Use the `many=True` flag when instantiating the serializer.',
|
'Use the `many=True` flag when instantiating the serializer.',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user