Per page parameter being ignored
gigili opened this issue · 2 comments
Hi,
I'm facing a problem where even tho I have set the per_page
and per_page_parameter
values the Pagination
is still using the default values.
I've used this setup:
pagination = Pagination(
css_framework='foundation',
per_page=end_limit,
per_page_parameter="rows",
page_parameter="page",
page=start_limit,
total=thl_total,
search=False,
record_name='transactions',
show_single_page=False
)
Where values are set like this:
start_limit = int(request.args.get("page")) if "page" in request.args.keys() else 1
end_limit = int(request.args.get("rows")) if "rows" in request.args.keys() else 5
The total is returned from the DB.
And here is the example of the data I have and what I'm getting:
Total records in db: 68
Per page: 5
Num of pagination links expected: 14
Num of pagination links rendered: 7
The db returns the correct amount of rows, but the pagination only displays 7 pages as that is how many there are if you use per_page = 10
and I tried to pass in the url both &rows=15&pp=15
and got the same pagination rendered on the screen. But if I manually go to ?page=10
it will display the correct data and show pagination links as: «12...345610»
I'm using
flask-paginate: 0.5.5
Python: 3.8.1
OS: linux (Manjaro x64)
per_page_parameter
is used for that you want to use another name instead of per_page
, you set it rows
and you need to use rows=end_limit
Thank you for the info, it is working now. From reading the docs I thought that this would only change the query string parameter in the url that the class is looking for and not the name of parameter for that functions as well.