title: How do you paginate a viewset using a paginator class?
body: <p>According to the documentation: </p>
  
  <pre><code>Pagination is only performed automatically if you're using the generic views or viewsets
  </code></pre>
  
  <p>But this doesn't seem to be the case. Here's what I have for my viewset:</p>
  
  <pre><code>views.py
  class EntityViewSet(viewsets.ViewSet):
      def list(self, request):
          queryset = Entity.objects.all()
          serializer = EntitySerializer(queryset, many=True)
          return Response(serializer.data)
  
      def retrieve(self, request, pk=None):
          queryset = Entity.objects.all()
          entity = get_object_or_404(queryset, pk=pk)
          serializer = EntitySerializer(entity)
          return Response(serializer.data)
  </code></pre>
  
  <p>Here's my urls</p>
  
  <pre><code>entity_list = views.EntityViewSet.as_view({'get':'list'})
  entity_detail = views.EntityViewSet.as_view({'get':'retrieve'})
      ...
      url(r'^entity/$', entity_list, name='entity-list'),
      url(r'^entity/(?P&lt;pk&gt;[0-9]+)/$', entity_detail, name='entity-detail'),
      ...
  </code></pre>
  
  <p>This is my pagination class</p>
  
  <pre><code>class PagePaginationWithTotalPages(pagination.PageNumberPagination):
      page_size = 30
      page_size_query_param = 'page_size'
      max_page_size = 1000
  
      def get_paginated_response(self, data):
          return Response({
              'next': self.get_next_link(),
              'previous': self.get_previous_link(),
              'count': self.page.paginator.count,
              'total_pages': self.page.paginator.num_pages,
              'results': data
          })
  </code></pre>
  
  <p>and I set it in settings.py</p>
  
  <pre><code>REST_FRAMEWORK = {
      'DEFAULT_PERMISSION_CLASSES': [
          'rest_framework.permissions.IsAuthenticated'
      ],
      'DEFAULT_PAGINATION_CLASS': 'myapp.pagination.PagePaginationWithTotalPages',
      'UNICODE_JSON': False,
  }
  </code></pre>
  
  <p>Now while this works for <code>ListAPIView</code> it doesn't appear to work for my viewset. Is there a step that I'm missing?</p>
  
  <p>For reference this works fine:</p>
  
  <pre><code>class EntitiesView(ListAPIView):
      serializer_class = EntitySerializer
  
      def get_queryset(self):
          parameters = get_request_params(self.request)
          qs = qs.filter(**parameters).distinct()
          return qs
  </code></pre>
  
  <p>EDIT: </p>
  
  <p>Changing it to use ModelViewset appears to have done the trick</p>
  
  <pre><code>class EntityViewSet(viewsets.ModelViewSet):
      queryset = Entity.objects.all()
      serializer_class = EntitySerializer
  
      def list(self, request):
          queryset = self.queryset
          parameters = get_request_params(self.request)
          if 'ordering' in parameters:
              queryset = queryset.order_by(parameters['ordering'])
              del parameters['ordering']
          queryset = queryset.filter(**parameters).distinct()
  
          page = self.paginate_queryset(queryset)
          if page is not None:
              serializer = self.get_serializer(page, many=True)
              return self.get_paginated_response(serializer.data)
          serializer = self.get_serializer(queryset, many=True)
          return Response(serializer.data)
  
      def retrieve(self, request, pk=None):
          entity = self.get_object()
          serializer = EntitySerializer(entity)
          return Response(serializer.data)
  </code></pre>