Я пытаюсь получить текущий номер страницы со страницы html для маршрутизации URL-адресов в функции update_table в отношении разбивки на страницы. Когда я получаю / распечатываю переменную 'page', я продолжаю получать None . Может ли кто-нибудь помочь мне с этим?
views.py
@app.route('/')
@app.route('/<int:page_num>')
def index(page_num=1):
historical_data = HR_historical.query.paginate(per_page=100, page=page_num, error_out=True)
return render_template('index.html',historical_data = historical_data)
@app.route('/update-table/<int:id>', methods=['GET','POST'])
def update_table(id):
updated = HR_historical.query.filter_by(id=id).first()
form = Historical_Data_Form(obj=updated)
if form.validate_on_submit():
form.populate_obj(updated)
db.session.add(updated)
db.session.commit()
**page = request.form.get('page')
print(page)
return redirect(url_for('index', page_num=page))**
return render_template('edit_historical_table.html',form=form)
index. html
<div class="pagination">
<a href="{{url_for(request.endpoint, page_num=historical_data.prev_num)}}">«</a>
{% for page in historical_data.iter_pages(left_edge=1, left_current=1, right_current=2, right_edge=1) %}
<form class="" method="post">
<input type="hidden" name="page" value="{{page}}">
</form>
{% if page %}
<a href="{{url_for('index', page_num=page)}}">{{page}}</a>
{% else %}
<a href="#"<«</a>
...
{% endif %}
{% endfor %}
<a href="{{url_for(request.endpoint, page_num=historical_data.next_num)}}">»</a>
</div>