Filter and Pagination in Django
Project description
Filter & Pagination in Django
- Filter your result-set
- Paginate your result-set as per object you want in your response
- It's a open source service.
- Easy to implement
- Fastest execution & High performance
Install with pip
pip install filter-and-pagination
Upgrade with pip
pip install filter-and-pagination --upgrade
How to implement
- install package by
pip install filter-and-pagination - import FilterPagination by
from filter_and_pagination import FilterPaginationin view.py - in your function writte code as bellow standards...
queryset = FilterPagination.filter_and_pagination(request, Customer)
serialize_data = CustomerSerializer(queryset['queryset'], many=True).data
resultset = {'dataset': serialize_data, 'pagination': queryset['pagination']}
- in this code
Customeris Django model & CustomerSerializeris a DRF Serializer class
- in the resultset it contains dataset & pagination data, In this format (API Response) link: https://github.com/ashish1997it/filter-pagination-dj#demo
- For the API request follow PostMan collection link: https://github.com/ashish1997it/filter-pagination-dj#postman in the header section it will take a parameter & request you customize as per your requirement
Demo / Example
Request:
- URL: http://127.0.0.1:8000/customers/api/v1/?name=jasmin
- Method: GET
Response:
{
"status_code": 200,
"status": "success",
"message": [
"Customer data retrieved successfully."
],
"data": {
"dataset": [{
"id": 166,
"name": "Jasmin",
"full_name": "Jasmin Perry",
"email": "nicolemathews@smith-anderson.net",
"contact_no_dail_code": "186",
"contact_no": "9831999092",
"dob": "1936-07-27",
"gender": 1,
"address": "466 Zuniga Trail Suite 955\nLake Brandonside, AL 22894",
"extra": {},
"created_at": "2020-01-11T10:09:24.780734Z",
"updated_at": "2020-01-11T10:09:24.780745Z"
}],
"pagination": {
"per_page": 20,
"current_page": 1,
"total_count": 1,
"total_pages": 1
}
}
}
- for more example follow: https://github.com/ashish1997it/filter-pagination-dj#demo
PyPi
- Project: filter-and-pagination
- link: https://pypi.org/project/filter-and-pagination/
GitHub
- Project: filter-pagination-dj
- link: https://github.com/ashish1997it/filter-pagination-dj
PostMan
- Collection: filter-and-pagination-in-GH-proj
- link: https://www.getpostman.com/collections/eae09a934fbc284bc062
Medium
- Article: Filter & Pagination in Django
- link: https://medium.com/@sondagarashish/filter-and-pagination-in-django-c0a61ff5f5c4
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 filter_and_pagination-1.1.14.tar.gz.
File metadata
- Download URL: filter_and_pagination-1.1.14.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b879133f182a3e0813776260c5747afaba1d23e1bd1248ee8798ce9c76a7ae7
|
|
| MD5 |
6945d8e46c73755db53c8d417e50eaf9
|
|
| BLAKE2b-256 |
d0f7c86759c499f1dd43881b65a62eb845f7a6a3e552f566f8af6b6e6ca73aa6
|