1+ {% load utils %}
2+
3+ {% if page_obj.has_other_pages %}
4+ < nav class ="pagination is-centered px-5 " role ="navigation " aria-label ="pagination ">
5+
6+ {% if page_obj.has_previous %}
7+ < a class ="pagination-previous "
8+ href ="?{% querystring request page=page_obj.previous_page_number %} ">
9+ Previous
10+ </ a >
11+ {% else %}
12+ < a class ="pagination-previous " disabled > Previous</ a >
13+ {% endif %}
14+
15+ {% if page_obj.has_next %}
16+ < a class ="pagination-next "
17+ href ="?{% querystring request page=page_obj.next_page_number %} ">
18+ Next
19+ </ a >
20+ {% else %}
21+ < a class ="pagination-next " disabled > Next</ a >
22+ {% endif %}
23+
24+ < ul class ="pagination-list ">
25+
26+ {% if page_obj.number > 3 %}
27+ < li >
28+ < a class ="pagination-link "
29+ href ="?{% querystring request page=1 %} "> 1</ a >
30+ </ li >
31+ {% if page_obj.number > 4 %}
32+ < li > < span class ="pagination-ellipsis "> …</ span > </ li >
33+ {% endif %}
34+ {% endif %}
35+
36+ {% for i in page_obj.paginator.page_range %}
37+ {% if i > = page_obj.number|add:-2 and i < = page_obj.number|add:2 %}
38+ {% if i == page_obj.number %}
39+ < li > < a class ="pagination-link is-current "> {{ i }}</ a > </ li >
40+ {% else %}
41+ < li >
42+ < a class ="pagination-link "
43+ href ="?{% querystring request page=i %} ">
44+ {{ i }}
45+ </ a >
46+ </ li >
47+ {% endif %}
48+ {% endif %}
49+ {% endfor %}
50+
51+ {% if page_obj.number < page _obj.paginator.num_pages|add:-2 %}
52+ {% if page_obj.number < page _obj.paginator.num_pages|add:-3 %}
53+ < li > < span class ="pagination-ellipsis "> …</ span > </ li >
54+ {% endif %}
55+ < li >
56+ < a class ="pagination-link "
57+ href ="?{% querystring request page=page_obj.paginator.num_pages %} ">
58+ {{ page_obj.paginator.num_pages }}
59+ </ a >
60+ </ li >
61+ {% endif %}
62+
63+ </ ul >
64+ </ nav >
65+ {% endif %}
0 commit comments