Hi there,
I'm using ViewSets exclusively and have an issue where pagination does not appear to be preserved when overriding list(). My goal is ideally to use differing serializers for list() and detail().
My ViewSet currently looks like this:
class MyViewSet(viewsets.ReadOnlyModelViewSet):
queryset = MyModel.objects.all()
serializer_class = PresentationSerializer
filter_backends = (filters.SearchFilter,)
search_fields = ['name', 'keywords', 'description']
max_paginate_by = 200
However, if I override list() I seem to unfortunately lose the pagination provide by the ModelViewSet
e.g.
class MyViewSet(viewsets.ReadOnlyModelViewSet):
model = MyModel
def list(self, request):
queryset = MyModel.objects.all()
filter_backends = (filters.SearchFilter,)
search_fields = ['name', 'keywords', 'description']
serializer = MyModelListSerializer(queryset, many=True)
return Response(serilaizer.data)
Clearly I'm doing something wrong. Any help would be greatly appreciated, thanks!