I am using the django paginator in the template. Its working ok, but not good when there\'s large numbers of pages.
views.py:
def blog(request):
You can use the following code.
FIRST Previous {% if page_obj.number|add:'-4' > 1 %} … {% endif %} {% for i in page_obj.paginator.page_range %} {% if page_obj.number == i %} {{ i }} {% elif i > page_obj.number|add:'-5' and i < page_obj.number|add:'5' %} {{ i }} {% endif %} {% endfor %} {% if page_obj.paginator.num_pages > page_obj.number|add:'4' %} … {% endif %} Next LAST