{% if bills.has_previous %} First Previous {% endif %} {% for num in bills.paginator.page_range %} {% if bills.number == num %} {{ num }} {% elif num > bills.number|add:'-3' and num < bills.number|add:'3' %} {{ num }} {% endif %} {% endfor %} {% if bills.has_next %} Next Last {% endif %}