title: How to serialize pagination objects in django-rest-framework from a haystack search?
body: <p>I currently have the following paginated results using the following view and serializer:</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>class DotaSearchViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
  
      serializer_class = DotaSearchSerializer
      permission_classes = (IsAuthenticated,)
      authentication_classes = (SessionAuthentication, BasicAuthentication)
  
      def get_queryset(self, *args, **kwargs):
          request = self.request
          results = EmptySearchQuerySet()
  
          if request.GET.get('q') is not None:
              query = request.GET.get('q')
              sqs = SearchQuerySet().filter(content=query)
              paginator = Paginator(sqs, 10)
  
              page = request.QUERY_PARAMS.get('page')
              try:
                  results = paginator.page(page)
              except PageNotAnInteger:
                  results = paginator.page(1)
              except InvalidPage:
                  results = paginator.page(paginator.num_pages)
  
          return results
  </code></pre>
  
  <p><strong>serializers.py</strong></p>
  
  <pre><code>class DotaSearchSerializer(serializers.Serializer):
      name = serializers.CharField()
      quality = serializers.CharField()
      type = serializers.CharField()
      rarity = serializers.CharField()
      hero = serializers.CharField()
      image = serializers.CharField()
      desc = serializers.CharField()
  
  class PaginatedDotaSearchItemsSerializer(pagination.PaginationSerializer):
  
      """
      Serializes page objects of results querysets.
      """
      start_index = serializers.SerializerMethodField('get_start_index')
      end_index = serializers.SerializerMethodField('get_end_index')
      num_pages = serializers.Field(source='paginator.num_pages')
  
      class Meta:
          object_serializer_class = DotaSearchSerializer
  
      def get_start_index(self, page):
          return page.start_index()
  
      def get_end_index(self, page):
          return page.end_index()
  
      def get_curr_page(self, page):
          return page.number
  </code></pre>
  
  <p>Now I am not sure if my pagination serializer is set up correctly, but how do I get it to serialise the pagination object within my results query.</p>
  
  <p>Thanks</p>