I have a ViewSet like this one to list users' data:
class Foo(viewsets.ViewSet):
def list(self, request):
queryset = User.objects.all()
serializer = UserSerializer(queryset, many=True)
return Response(serializer.data)
I want to turn on pagination like the default pagination for ModelViewSet:
{
"count": 55,
"next": "http://myUrl/?page=2",
"previous": null,
"results": [{...},{...},...,{...}]
}
The official doc says:
Pagination is only performed automatically if you're using the generic views or viewsets
...but my resultset is not paginated at all. How can I paginate it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…