4

ページに20行のコンテンツを表示し、S.No 1から20を表示できます。ページネーターを使用して次のページに移動し、各ページで次のページを選択すると前のページに戻ります。 20のみ。次のページに移動すると表示されず、前のページに移動しても減少しません。S.Noを昇順で表示する方法

{% for child in children.object_list %}
<tr><td width="15%">strong>Sl.no</strong>{{forloop.counter}}</td>
</tr>
{% endfor %}


<div class="pagination">
    <span class="step-links">
        {% if children.has_next %}
            <a href="?page={{ children.next_page_number }}"> Previous </a>
        {% endif %}

        <span class="current">
            Page {{ children.number }} of {{ children.paginator.num_pages }}.
        </span>

        {% if children.has_previous %}
            <a href="?page={{ children.previous_page_number }}"> Next </a>
        {% endif %}
 <br>
    </span>
</div>
4

2 に答える 2

5

テンプレートで、アイテム番号を表示するためにこれを書きます

{% for child in children.object_list %}
    <tr><td width="15%">strong>Sl.no</strong>
        {{ forloop.counter0|add:children.start_index}} </td>
    </tr>
{% endfor %}

{{forloop.counter}}常に0から始まります。

于 2012-09-17T10:01:53.177 に答える
0

私はいつもこの種のことのためにdjango-paginationを使います。いくつかのテンプレートタグを使用して、すべてのハードワークを実行します...

于 2012-09-17T09:43:43.230 に答える