Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

djangorestframework-custom-paginations

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djangorestframework-custom-paginations

Custom paginations for Django REST Framework

  • 1.2.2
  • PyPI
  • Socket score

Maintainers
2

django-rest-framework-custom-paginations

Custom paginations for django rest framework

Compatibility

work with :

  • Python 2.7 / 3.4
  • Dango 1.6 / 1.7
  • Django Rest Framework 2.4 / 3.0 / 3.1 / 3.2 / 3.3

Installation

Install the package from pypi: ::

pip install djangorestframework-custom-paginations

Add the application in your django settings: ::

DJANGO_APPS = ('rest_framework_custom_paginations',)

Configure your rest framework for DRF >= 3.1: ::

REST_FRAMEWORK = {
    'DEFAULT_PAGINATION_CLASS': 'rest_framework_custom_paginations.classes.SporePagination',
}

or configure your rest framework for DRF < 3.1: ::

REST_FRAMEWORK = {
    'DEFAULT_PAGINATION_SERIALIZER_CLASS': 'rest_framework_custom_paginations.paginations.SporePaginationSerializer'
}

Usage

Add the following parameters in a ListAPIView : ::

class PersonList(generics.ListAPIView):
    """ list of person """
    ...
    paginate_by = 100
    paginate_by_param = 'page_size'
    max_paginate_by = 500

Example

Results of Spore Pagination : ::

{
    "count": 532,
    "next": "http://myurls/persons.json?structure=mystructure&page=3",
    "next_params": {
        "page": 3,
        "structure": "mystructure"
    },
    "num_pages": 6,
    "previous": "http://myurls/persons.json?structure=mystructure&page=1",
    "previous_params": {
        "page": 1,
        "structure": "mystructure"
    },
    "results": [
        ...
    ]
}

Keywords

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