html django bootstrap3分页

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html django bootstrap3分页相关的知识,希望对你有一定的参考价值。

<ul class="pagination">
    {% if page_obj.has_previous %}
        <li>
            <a href="?page={{ page_obj.previous_page_number }}">
                {% else %}
        <li class="disabled">
        <a href="#">
    {% endif %}
    <span>&laquo;</span>
    </a>
    </li>

    {% with active_page=page_obj.number %}
        {% for page_number in paginator.page_range %}
            {% if active_page > 4 and page_number < active_page|add:"-3" %}
                {% if page_number == 1 %}
                    <li {% if page_number == active_page %}class="active"{% endif %}>
                        <a href="?page={{ page_number }}">{{ page_number }}</a>
                    </li>
                {%  endif %}
            {% elif active_page > 4 and page_number == active_page|add:"-3" %}
                <li class="disabled">
                    <a href="#">...</a>
                </li>
            {% elif active_page < paginator.num_pages|add:"-4" and page_number > active_page|add:3 %}
                {% if page_number == paginator.num_pages %}
                    <li {% if page_number == active_page %}class="active"{% endif %}>
                        <a href="?page={{ page_number }}">{{ page_number }}</a>
                    </li>
                {%  endif %}
            {% elif active_page < paginator.num_pages|add:"-4" and page_number == active_page|add:3 %}
                {# show '...' #}
                <li class="disabled">
                    <a href="#">...</a>
                </li>
            {% else %}
                {# show the page number as normal #}
                <li {% if page_number == active_page %}class="active"{% endif %}>
                    <a href="?page={{ page_number }}">{{ page_number }}</a>
                </li>
            {% endif %}
        {% endfor %}
    {% endwith %}

    {% if page_obj.has_next %}
        <li>
            <a href="?page={{ page_obj.next_page_number }}">
                {% else %}
        <li class="disabled">
        <a href="?page=#">
    {% endif %}
    <span>&raquo;</span>
    </a>
    </li>
</ul>

以上是关于html django bootstrap3分页的主要内容,如果未能解决你的问题,请参考以下文章

html模板中的Django分页

Django - Ajax分页

python之路--web--2--Django-9-分页

python测试开发django-191.Bootstrap3 轮播图(Carousel)

Python3.4+Django1.9+Bootstrap3

Python Day71 django分页及session介绍