I am using paginate of sqlalchemy to paginate my query like following but in my front page I want to implement a next button (or a numerical page navigation links like 1,2,3,4..) and when it reaches at the last page I don't want to show user the next button (or know the maximum number of pages available in the page navigation). I would prefer not to use another database query in sqlalchemy. What is the most convenient way achieve this?
I am using following fo pagination:
Pagination class docs.
query = (Blog.query.filter(Blog.title.like('%'+query+'%')) .paginate(page=start, per_page=size))
Then you can use
query.has_next properties to check if previous or next pages exist.