A small library to paginate through json objects
Project description
USAGE
To import:
from pypagination import paginate
Call the paginate function:
paginate(150):
{
totalItems: 150,
currentPage: 1,
pageSize: 10,
totalPages: 15,
startPage: 1,
endPage: 10,
startIndex: 0,
endIndex: 9,
pages: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
}
paginate(150, 7): totalItems: 150, currentPage: 7, pageSize: 15
{
totalItems: 150,
currentPage: 7,
pageSize: 10,
totalPages: 15,
startPage: 2,
endPage: 11,
startIndex: 60,
endIndex: 69,
pages: [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
}
paginate(150, 7, 15, 5) totalItems: 150, currentPage: 7, pageSize: 15, maxPages: 5
{
totalItems: 150,
currentPage: 7,
pageSize: 15,
totalPages: 10,
startPage: 5,
endPage: 9,
startIndex: 90,
endIndex: 104,
pages: [ 5, 6, 7, 8, 9 ]
}
BRIEF
The paginate function accepts the following parameters:
totalItems (required)
- the total number of items to be pagedcurrentPage (optional)
- the current active page, defaults to the first pagepageSize (optional)
- the number of items per page, defaults to 10maxPages (optional)
- the maximum number of page navigation links to display, defaults to 10
The output of the paginate function is an object containing all the information needed to display the current page of items in the view and the page navigation links.
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
pypagination-0.0.3.tar.gz
(2.2 kB
view details)
Built Distribution
File details
Details for the file pypagination-0.0.3.tar.gz
.
File metadata
- Download URL: pypagination-0.0.3.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a44a3ccb16908405e0ae7edf7402bf9762b463e5591f835d9a43c899296b754 |
|
MD5 | c5ccd1a186eb610982830f9f0a626749 |
|
BLAKE2b-256 | f9315545398c726aec4271d3e4893c96e163ef88f1e21e30d92b59cf182b72f2 |
File details
Details for the file pypagination-0.0.3-py2-none-any.whl
.
File metadata
- Download URL: pypagination-0.0.3-py2-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bcae86386784e56ee0a0e1c82d8e63dd1e8ae213be16069953abb47f1a28462 |
|
MD5 | ecac0b015389aabc265aec5126355295 |
|
BLAKE2b-256 | c8c8581e42f59da7e7001df96e49be659d801288641b36a85713c2b8d462089d |