title: DRF - Paginated response - append list of all ids
body: <p>I have a &quot;next object&quot; feature on my website but I use pagination. I would like add &quot;ids&quot; field that contains ids of all objects filtered and sorteded into the paginated response.</p>
  <p>Everything that I tried returns only a list of current page ids.</p>
  <pre><code>class StandardResultsSetPagination(PageNumberPagination):
      page_size = 20
      page_size_query_param = 'page_size'
      max_page_size = 20
  
  
      def get_paginated_response(self, data, list_of_ids):
          return Response(OrderedDict([
              ('count', self.page.paginator.count),
              ('next', self.get_next_link()),
              ('previous', self.get_previous_link()),
              ('results', data),
              ('ids', list_of_ids)
          ]))
  
      
  
  
  class RealestateViewSet(ModelViewSet):
      ...
      pagination_class = StandardResultsSetPagination
  
      def get_paginated_response(self, data, list_of_ids):
          &quot;&quot;&quot;
          Return a paginated style `Response` object for the given output data.
          &quot;&quot;&quot;
          assert self.paginator is not None
          return self.paginator.get_paginated_response(data, list_of_ids)
  
      def list(self, request, *args, **kwargs):
          queryset = self.filter_queryset(self.get_queryset())
  
          page = self.paginate_queryset(queryset)
          if page is not None:
              serializer = self.get_serializer(page, many=True)
              return self.get_paginated_response(serializer.data, list(queryset.values_list('id', flat=True)))
  
          serializer = self.get_serializer(queryset, many=True)
          return Response(serializer.data)
  </code></pre>
  <p>This returns a list of 20 ids instead of all filtered objects ids.</p>
  <p>Do you know how to do that?</p>