1
{% for i in paginated_queryset.num_pages %}
    {{ i }}
{% endfor%}

paginated_quertser.num_pages = 9

I want to output like this 1 2 3 4 5 6 7 8 9

I also read django pagination document but in the document not given example like this and I am beginner in django

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
Shatish Desai
  • 575
  • 6
  • 20

1 Answers1

2

You can iterate over the .page_range [Django-doc] of the Paginator of the page:

{% for i in paginated_queryset.paginator.page_range %}
    {{ i }}
{% endfor %}

or if this is the Paginator (not the Page), with:

{% for i in paginator.page_range %}
    {{ i }}
{% endfor %}
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555