A
A
aial2017-06-22 17:35:26
Flask
aial, 2017-06-22 17:35:26

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>

code in views.
@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)


This is how it looks like it should show 10 lists.
848e11f0244e4f29bdf91cda7b11a242.PNG
ps or can you tell me how to make a paginator or what library to use

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2017-06-22
@aial

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 question

Ask a Question

731 491 924 answers to any question