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):
Another shorter solution with template is compare current forloop.counter with certain range.
with bootstrap I use this template
{% if page_obj.has_previous %} « begin {% endif %} {% for n in page_obj.paginator.page_range %} {% if page_obj.number == n %} {{ n }}(current) {% elif n > page_obj.number|add:'-3' and n < page_obj.number|add:'3' %} {{ n }} {% endif %} {% endfor %} {% if page_obj.has_next %} » end {% endif %}