Answer the question
In order to leave comments, you need to log in
Why doesn't it show N-th number of records in one page?
Why doesn't it show N number of records in one page using Python language with flask framework. I use the flask-paginate library to paginate the list and in one page it does not show the Nth number of records, but shows the entire list.
HTML code.
{{ pagination.info }}
{{ pagination.links }}
<table class="table table-condensed table-hover">
<thead>
<tr>
<th><input type="checkbox" id="selectAll"/></th>
<th>#</th>
<th>Наименование организации</th>
<th>Электронная почта</th>
</tr>
</thead>
<tbody>
{% for object in data %}
<tr>
<td><input type="checkbox" name="optradio"></td>
<td>{{loop.index + (page - 1) * per_page}}</td>
<td>
{{object.name}}
</td>
<td>
{{object.mails}}
</td>
</tr>
{% endfor %}
</tbody>
</table>
@app.route("/", methods=["POST", "GET"])
def index():
data = Mails.query.all()
page = int(request.args.get('page', 1))
pagination = Pagination(page=page, total=len(data), per_page=ITEMS_PER_PAGE, css_framework='bootstrap3',
record_name='data')
return render_template("index.html", page=page, per_page=ITEMS_PER_PAGE, data=data, pagination=pagination)
Answer the question
In order to leave comments, you need to log in
So you run through the entire collection through for! Somehow you need to limit yourself ...
like
Here is the recipe - https://stackoverflow.com/questions/43103585/pytho...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question