x=0(в представлении)
{% for num in products.paginator.page_range %}
{% if num >= adapt_num and x<6 %}
x+=1
<a href="?page={{ num }}"><section class="pagination_number">{{ num }}</section></a>
{% endif %}
{% endfor %}
adapt_num = products.number - 3
def view_paginator_num():
x = 0
pag_num_list = []
for num in paginator.page_range:
if num >= adapt_num and x < 7:
x += 1
pag_num_list += [num]
return pag_num_list
pag_num_list = view_paginator_num()