Custom paginations for Django REST Framework
Project description
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
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 :
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": [ ... ] }
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for djangorestframework-custom-paginations-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36667e00fc2a9ff9ac4d1da77c39c9f1198322c68c475eb3d87cabdf8a105d4d |
|
MD5 | 315bf7faa4202504bf09a2aeed70400f |
|
BLAKE2b-256 | 57e3a2cff14513615cfe2b838370d7abf238cdf56a3056244547688cfe8f1935 |