paginate_by如何显示省略号-Django

时间:2018-06-22 07:30:49

标签: html pagination django-views ellipsis paginate

我有一个用Django构建的网站,我想像这样分页(/ admin) enter image description here 但是我的页面分页如下: enter image description here 我有一个list.html如下:

{% if is_paginated %}
  <ul class="pagination">
    {% if page_obj.has_previous %}
      <li><a href="?page={{ page_obj.previous_page_number }}">&laquo;</a></li>
    {% else %}
      <li class="disabled"><span>&laquo;</span></li>
    {% endif %}
    {% for i in paginator.page_range %}
      {% if page_obj.number == i %}
        <li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
      {% else %}
        <li><a href="?page={{ i }}">{{ i }}</a></li>
      {% endif %}
    {% endfor %}
    {% if page_obj.has_next %}
      <li><a href="?page={{ page_obj.next_page_number }}">&raquo;</a></li>
    {% else %}
      <li class="disabled"><span>&raquo;</span></li>
    {% endif %}
  </ul>
</div>
{% endif %}

和view.py:

ProjectListView(ListView):
    paginate_by = 20

0 个答案:

没有答案