1
{% if chunk.number|diff:1 > 3 %}
...
{% endif %}
{% for i in chunk.paginator.page_range|slice:'1:-1' %}
{% if i == chunk.number %}
{{ i }}
{% elif i > chunk.number|diff:3 and i < chunk.number|add:3 %}
{{ i }}
{% endif %}
{% endfor %}
{% if num_pages|diff:chunk.number > 3 %}
...
{% endif %}
{{ num_pages }}