Django REST framework limit/offset pagination with multiple queryset support
Project description
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:
$ pip install rest_framework_pagination
Usage
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file rest_framework_pagination-0.0.1.tar.gz.
File metadata
- Download URL: rest_framework_pagination-0.0.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.6rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee76bb12d12936a369a51cab2901eec87890d4d15b0dc0fd910737884e9c1198
|
|
| MD5 |
e19c944fd7edce4ec431eb8877413df1
|
|
| BLAKE2b-256 |
73553224b177dce52dcff62dd5136ca6ccc24870b54500c8aea306da17b6069a
|