【发布时间】:2016-06-28 18:35:13
【问题描述】:
我正在开发一个 Django 应用程序以及我们使用分页的页面之一。我有大约 200 页,如果我在中间的某个地方,那么它有来自第 1-4 页的链接,显示我所在页面后面的 4 页,我所在页面之后的 3 页和最后 4 页。看起来像this
我希望它一次显示更少的页面,可能是前 2 个、最后 2 个以及我所在的当前页面 +/- 2。
{% extends 'base.html' %}
{% load pagination_tags %}
{% load staticfiles %}
{% block body_block %}
{% autopaginate art 4 %}
<div class="container">
{% if item%}
{% for x in item %}
<div class="floated_img">
{% if x.picture %}
<img src="{{ x.picture.url }}" name="aboutme" width="140" height="140"
class="img-rounded" class="img-responsive">
{% else %}
<img src="{% static "images/generic.jpg" %}" name="aboutme" width="140" height="140"
class="img-rounded" class="img-responsive">
{% endif %}
<div class="table-responsive">
<p style="text-align: center;">
<strong>{{ x.name }}</strong><br>
<strong>{{ x.type }}</strong><br>
<strong>{{ x.price }}</strong>
</div>
</p>
</div>
{% endfor %}
<br>
</div>
{% endif %}
<br>
{% paginate %}
{% endblock %}
我还没有为分页编写任何 python 文件并且刚刚导入了一些东西,我想我将不得不对一些分页文件进行更改并将它们存储在我的项目中以覆盖它们但不知道如何去关于这样做。
非常感谢您的帮助,并希望我就我的问题提供了足够的信息
【问题讨论】:
标签: python django pagination