Answer the question
In order to leave comments, you need to log in
How to make "compact" pagination in django?
Hello.
I ran into a situation that I had about 600 materials, and if I break them down 25 per page, we get 24 pages. And the pagination that is provided on the official django site gives us all 24 pages on the site.
Do not tell me how you can make this whole thing compact, so that let's say it displays the first three and the last page. And this bubble moved behind the pages?
So far in the template I use this thing:
<div class="row">
<div class="small-12 medium-12 large-12 column pagination_forum_block">
<ul class="pagination">
{% if forumpage.has_previous %}
<li class="arrow"><a href="?page={{ forumpage.previous_page_number }}"><i class="fa fa-angle-double-left" aria-hidden="true"></i></a></li>
{% else %}
{# <li class="arrow unavailable"><a href="">«</a></li>#}
{% endif %}
{% for page in forumpage.paginator.page_range %}
{% if page == forumpage.number %}
<li class="current"><a href="?page={{ page }}">{{ page }}</a></li>
{% else %}
<li><a href="?page={{ page }}">{{ page }}</a></li>
{% endif %}
{% endfor %}
{% if forumpage.has_next %}
<li class="arrow"><a href="?page={{ forumpage.next_page_number }}"><i class="fa fa-angle-double-right" aria-hidden="true"></i></a></li>
{% else %}
{# <li class="arrow unavailable"><a href="">»</a></li>#}
{% endif %}
</ul>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Leave two sections:
Essentially:
if page.has_previous
page.number #active link
else
page.number
if page.has_next
page.paginator.num_pages #active link
else
page.paginator.num_pages
What will happen -something like (depending on design) " Previous ................... Next "
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question