标签作用:用于输出列表分页代码
{% if is_paginated %}
{% if page_obj.has_previous %}
<li>
<a href="{% url "webapp:page" url page_obj.previous_page_number %}{% if request.GET.search %}?search={{ request.GET.search }}{% endif %}{% if request.GET.fen %}&fen={{ request.GET.fen }}{% endif %}"
><span aria-hidden="true">«</span> </a>
</li>
{% endif %}
{% for page in page_range %}
{% if page_obj.number == page %}
<li><a style="background-color: #ddd;">{{ page }}</a></li>
{% elif page == '...' %}
{% else %}
<li>
<a href="{% url "webapp:page" url page %}{% if request.GET.search %}?search={{ request.GET.search }}{% endif %}{% if request.GET.fen %}&fen={{ request.GET.fen }}{% endif %}">{{ page }}</a>
</li>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<li>
<a href="{% url "webapp:page" url page_obj.next_page_number %}{% if request.GET.search %}?search={{ request.GET.search }}{% endif %}{% if request.GET.fen %}&fen={{ request.GET.fen }}{% endif %}"aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
{% endif %}
{% endif %}
适配了搜索分页,和普通列表分页全部可用,上一页、下一页、和页码