title: How to Paginate within an action in Django Rest Framework
body: <p>Good afternoon community, I have a question about the Django rest framework page. In this case, I manage to do it in the viewset, but in a class action I have not been able to achieve it.</p>
  <p>Attached are images of the responses in the Django rest framework:</p>
  <p><img src="https://i.stack.imgur.com/AirP4.png" alt="Response in viewset" /></p>
  <p>Action:</p>
  <p><img src="https://i.stack.imgur.com/bIm8x.png" alt="Response in class action" /></p>
  <pre><code>class PostPageNumberPagination(PageNumberPagination):
      page_size=10
  
  class InterfacesViewSet(viewsets.ModelViewSet):
       
      queryset=Interfaces.objects.all()
      serializer_class=InterfaceSerializer
      pagination_class=PostPageNumberPagination
  
  # La siguiente funcion es un decorador(funciones extra) de la clase RegistrosViewSet para poder manipular los datos que voy a presentar de acuerdo a la URL que se le asigne con el url_path
  # El siguiente action actua para poder presentar todos los datos de todos los objetos
      @action(methods=['get'],detail=False,url_path='registros-data-table',url_name='registros_data_table')
      def registros_data_table(self, request):
              paginator=PostPageNumberPagination
              return Response(
                      {
                  'id_interface':interface.id_interface,
                  'id_EquipoOrigen':interface.id_EquipoOrigen_id,
                  'EquipoOrigen':interface.id_EquipoOrigen.nombre,
                  'LocalidadOrigen':interface.id_EquipoOrigen.localidad,
                  'CategoriaOrigen':interface.id_EquipoOrigen.categoria,
                  'id_PuertoOrigen':interface.id_PuertoOrigen_id,
                  'PuertoOrigen':interface.id_PuertoOrigen.nombre,
                  'estatus':interface.estatus,
                  'etiqueta_prtg':interface.etiqueta_prtg,
                  'grupo':interface.grupo,
                  'if_index':interface.if_index,
                  'bw':interface.bw,
                  'bw_al':interface.bw_al,
                  'id_prtg':interface.id_prtg,
                  'ospf':interface.ospf,
                  'description':interface.description,
                  'id_EquipoDestino':interface.id_EquipoDestino_id,
                  'EquipoDestino':interface.id_EquipoDestino.nombre,
                  'LocalidadDestino':interface.id_EquipoDestino.localidad,
                  'CategoriaDestino':interface.id_EquipoDestino.categoria,
                  'id_PuertoDestino':interface.id_PuertoDestino_id,
                  'PuertoDestino':interface.id_PuertoDestino.nombre,
                  'ultima_actualizacion':interface.ultima_actualizacion,
                      }
                  for interface in Interfaces.objects.all()
              )
  </code></pre>
  <p><strong>Update</strong>: I made the method provided by the friend @bdoubleu but I get that the objects are not being paginated, that is to say in all the pages the total number of objects appears.</p>
  <p><a href="https://i.stack.imgur.com/ntD1K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ntD1K.png" alt="Screenshot without pagination" /></a></p>
  <p><a href="https://i.stack.imgur.com/MJJga.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MJJga.png" alt="Screenshot with pagination, but it does not have an effect" /></a></p>