from project.pagination import MyPaginator
from project.serializers import MySerializer
class MyViewSet(GenericViewSet):
serializer_class = MySerializer
pagination_class = MyPaginator
def get_queryset(self):
#Get the objects from the legacy DB
return Database().table("customers").all()
def list(self, request):
#Get the queryset (not a django queryset)
queryset = self.get_queryset()
#Run it through the paginator
paginator = pagination_class()
objects = paginator.paginate_queryset(queryset , request)
#Serialize the list of objects
serializer = self.serializer_class(objects, many=True)
#return Response(serializer.data)
return paginator.get_paginated_response(serializer.data)
This actually works well and the browsable API shows paginated data with links to the next page. What I don't get is the HTMl pagination controls. The docs say to set
as True, but it is and no luck.