Исправлена передача GET-параметров в пагинации
- Убран нерабочий хак с params.pop - Все ссылки пагинации теперь явно передают параметры: * q (поисковый запрос) * has_notes (фильтр заметок) * no_phone (фильтр отсутствия телефона) * no_email (фильтр отсутствия email) - Пагинация теперь работает корректно с сохранением всех фильтров
This commit is contained in:
@@ -128,19 +128,16 @@
|
||||
|
||||
<!-- Pagination -->
|
||||
{% if page_obj.has_other_pages %}
|
||||
{# Сохраняем все GET-параметры кроме page #}
|
||||
{% with params=request.GET.copy %}
|
||||
{% if params.page %}{{ params.pop|slice:":0" }}{% endif %}
|
||||
<nav aria-label="Page navigation" class="mt-3">
|
||||
<ul class="pagination pagination-sm justify-content-center mb-0">
|
||||
{% if page_obj.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="?page=1&{{ params.urlencode }}" title="Первая страница">
|
||||
<a class="page-link" href="?page=1{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}{% if request.GET.has_notes %}&has_notes=on{% endif %}{% if request.GET.no_phone %}&no_phone=on{% endif %}{% if request.GET.no_email %}&no_email=on{% endif %}" title="Первая страница">
|
||||
««
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="?page={{ page_obj.previous_page_number }}&{{ params.urlencode }}" title="Предыдущая">
|
||||
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}{% if request.GET.has_notes %}&has_notes=on{% endif %}{% if request.GET.no_phone %}&no_phone=on{% endif %}{% if request.GET.no_email %}&no_email=on{% endif %}" title="Предыдущая">
|
||||
«
|
||||
</a>
|
||||
</li>
|
||||
@@ -163,7 +160,7 @@
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="?page={{ num }}&{{ params.urlencode }}">{{ num }}</a>
|
||||
<a class="page-link" href="?page={{ num }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}{% if request.GET.has_notes %}&has_notes=on{% endif %}{% if request.GET.no_phone %}&no_phone=on{% endif %}{% if request.GET.no_email %}&no_email=on{% endif %}">{{ num }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@@ -172,12 +169,12 @@
|
||||
|
||||
{% if page_obj.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="?page={{ page_obj.next_page_number }}&{{ params.urlencode }}" title="Следующая">
|
||||
<a class="page-link" href="?page={{ page_obj.next_page_number }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}{% if request.GET.has_notes %}&has_notes=on{% endif %}{% if request.GET.no_phone %}&no_phone=on{% endif %}{% if request.GET.no_email %}&no_email=on{% endif %}" title="Следующая">
|
||||
»
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}&{{ params.urlencode }}" title="Последняя страница">
|
||||
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}{% if request.GET.has_notes %}&has_notes=on{% endif %}{% if request.GET.no_phone %}&no_phone=on{% endif %}{% if request.GET.no_email %}&no_email=on{% endif %}" title="Последняя страница">
|
||||
»»
|
||||
</a>
|
||||
</li>
|
||||
@@ -191,7 +188,6 @@
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
Reference in New Issue
Block a user