diff options
| author | Tom Christie | 2013-01-26 20:54:41 +0000 |
|---|---|---|
| committer | Tom Christie | 2013-01-26 20:54:41 +0000 |
| commit | a51bca32fd26ae954228b9026b18ebeea81ad8e2 (patch) | |
| tree | d7853e6d1af3d90ee897153915fe1fc69c647cc7 /rest_framework/serializers.py | |
| parent | b41f258ee548e6746f15ad0829f6d29a5b66aefd (diff) | |
| download | django-rest-framework-a51bca32fd26ae954228b9026b18ebeea81ad8e2.tar.bz2 | |
Fix issues with custom pagination serializers
Diffstat (limited to 'rest_framework/serializers.py')
| -rw-r--r-- | rest_framework/serializers.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index c3876809..6ecc7b45 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -2,6 +2,7 @@ import copy import datetime import types from decimal import Decimal +from django.core.paginator import Page from django.db import models from django.forms import widgets from django.utils.datastructures import SortedDict @@ -273,7 +274,11 @@ class BaseSerializer(Field): """ Serialize objects -> primitives. """ - if hasattr(obj, '__iter__'): + # Note: At the moment we have an ugly hack to determine if we should + # walk over iterables. At some point, serializers will require an + # explicit `many=True` in order to iterate over a set, and this hack + # will disappear. + if hasattr(obj, '__iter__') and not isinstance(obj, Page): return [self.convert_object(item) for item in obj] return self.convert_object(obj) |
