D
D
Dinxor2021-07-26 21:48:04
Flask
Dinxor, 2021-07-26 21:48:04

How to redirect to the first page of pagination in Flask when applying a filter?

There is a page with pagination according to the template ./pagenumber/, everything works. But if you go to the last page, and then apply the filter, and as a result, the number of pages will decrease, the "no records" situation occurs. Although they are on the first page for sure. How is it ideologically correct to reset the page number in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dinxor, 2021-07-30
@Dinxor

Found the solution myself, changed the filter in the page template. It was

<form "{{request.path}}" method="get">
<input name="flt" value="{{flt_s}}">
<button type="search" >Найти</button>
</form>

Fixed the first line, as a result of which I got rid of the transfer of the page number when using the search. It became
<form action="/{{request.path.split('/')[1]}}" method="get">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question