Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per page parameter being ignored #77

Closed
gigili opened this issue Mar 7, 2020 · 2 comments
Closed

Per page parameter being ignored #77

gigili opened this issue Mar 7, 2020 · 2 comments

Comments

@gigili
Copy link

gigili commented Mar 7, 2020

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)
@lixxu
Copy link
Owner

lixxu commented Mar 8, 2020

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

@gigili
Copy link
Author

gigili commented Mar 8, 2020

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.

@gigili gigili closed this as completed Mar 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants