我如何在django中使用分页

时间:2013-09-13 05:11:15

标签: python html django pagination

代码不清楚,想在django模板中使用分页。

views.py中有什么? 什么在设置中,py ??

模板是: -

<div id="contentwrapper">
                <div class="main_content">
                        <div class="row-fluid">
                <div class="span12">
                      <h3 class="heading">Application View</h3>
                        <div class="row-fluid">

                            <table class="table table-striped table-bordered mediaTable">
                                <thead><tr><th>App Id</th><th>Job Title</th><th>oDesk Id</th><th>Client Spent</th><th>Job Type</th><th>Notes</th><th colspan=2>Action</th></tr>
</thead>
<tbody>
{% for i in getvalue %}
 <tr>

<td>{{ i.app_id }}</td>
<td>{{ i.job_title }}</td>
<td>{{ i.odesk_id }}</td>
<td>{{ i.client_spent }}</td>
<td>{{ i.job_type }}</td>
<td>{{ i.notes_type }}</td>
<td><a href="/interview/?id={{i.app_id}}&oid={{i.odesk_id}}" title="Interview"><i class="splashy-document_letter_okay"></i></a></td>

<td><a href="/del/?id={{i.app_id}}" title="Remove"><i class="splashy-document_letter_remove"></i></a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

2 个答案:

答案 0 :(得分:0)

您可以使用django的默认分页选项 看...,

https://docs.djangoproject.com/en/dev/topics/pagination/

答案 1 :(得分:0)

使用django-endless-pagination在不到5分钟内完成分页并运行:

http://django-endless-pagination.readthedocs.org/en/latest/

pip install django-endless-pagination

在已安装的应用中添加endless-pagination

最后,在您的模板上执行以下操作:

{% load endless %}

{% paginate entries %}
{% for entry in entries %}
    {# your code to show the entry #}
{% endfor %}
{% show_pages %}