I'm still working on my project and now it comes to searching the data. Usually I do a post request do a route, giving the search string as parameter:
@bp.route('/search', methods=['GET', 'POST'])
def search():
if request.method == 'POST':
resp = db.session.query(MyTable).filter(MyTable.name.like('%'+request.form['search_name']+'%')).all()
... # do something else
My problem is how to implement pagination when the search results exceed the maximum amount of items per page.
Pagination itself won't be the problem when displaying data without any user action, there are several ways to do that either with Flask-paginate or via Flask-SQLAlchemy's paginate() function. But how to transfer the search string through the other pages since page is given as GET parameter with ?page=x
and the search string is a POST parameter?
I somehow ran out of mind and did a lot of investigations on the net, but I only got results on doing pagination on normal data, not search results.
Could somehow give me an advice?
Many thanks in advance, regards, Thomas