Socket
Socket
Sign inDemoInstall

rest-framework-pagination

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rest-framework-pagination

Django REST framework limit/offset pagination with multiple queryset support


Maintainers
1

Django Rest Framework Multiple Queryset Pagination

This is django rest framework pagination based on LimitOffsetPagination with multiple queryset support

Installation

Install the package with pip:

.. code-block:: sh

$ pip install rest_framework_pagination

Usage

.. code-block:: python

from rest_framework.viewsets import GenericViewSet
from rest_framework.mixins import ListModelMixin
from rest_framework_pagination.pagination import MultiQuerysetPagination


class MainPageView(ListModelMixin, GenericViewSet):
    serializer_class = serializers.MainPageSerializer
    pagination_class = MultiQuerysetPagination
    querysets = [models.Person.objects.all(),
                 models.Order.objects.all(),
                 models.Address.objects.all()]

    def get_queryset(self):
        return self.querysets

    def paginate_querysets(self, querysets):
        return self.paginator.paginate(querysets, self.request, view=self)

    def list(self, request, *args, **kwargs):
        page = self.paginate_querysets(self.get_queryset())
        serializer = self.get_serializer_class()(page, many=True)
        return self.get_paginated_response(serializer.data)

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc