1👍
✅
The problem is not the pagination, but the way you serialize your data: serializers.serialize
is built to serialize Django model instances (from a list or a QuerySet
), nothing else. You can use the json
module from the python stdlib to serialize ‘raw’ dictionaries, try for example:
import json
print json.dumps({'your': 'dict'})
You might need to convert the ValuesQuerySet
to a vanilla list-of-dicts to convince the json
module to work, though:
# [...]
data = paginator.page(1)
print json.dumps(list(data))
👤sk1p
Source:stackexchange.com