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:
Ross McFarland 2013-10-19 20:05:38 -07:00
parent c3aeb16557
commit 18d8f818e0

View File

@ -520,7 +520,7 @@ class BaseSerializer(WritableField):
if self.many is not None:
many = self.many
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:
warnings.warn('Implict list/queryset serialization is deprecated. '
'Use the `many=True` flag when instantiating the serializer.',