Created
October 30, 2019 10:48
-
-
Save giasuddin90/05cb8294bccebb9480a2c4dd9f8789ab to your computer and use it in GitHub Desktop.
python script for generating pagination by using total number of row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'giasuddin' | |
| def pager(total_row=None, item_per_page=None): | |
| """ | |
| We are using this function for pagination database total row. | |
| Then using offset for query | |
| """ | |
| pages = {} | |
| total_page = total_row/item_per_page | |
| if total_row % item_per_page != 0 and total_page > 1: | |
| total_page += 1 | |
| for page in range(1, int(total_page) + 1): | |
| m = page - 1 | |
| pages[page] = item_per_page * m | |
| return pages | |
| if __name__ == '__main__': | |
| print(pager(100, 20)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment