feat: add pagination and color filter to catalog view and templates
All checks were successful
Build and Push Docker Image / build (push) Successful in 24s

- Implemented pagination for catalog items with Django's Paginator
- Updated `item-list.html` to include pagination controls
- Added color filtering logic to catalog view with support for `Color` model
- Enhanced `side-bar.html` with a dynamic color dropdown filter
- Adjusted filtering URL logic to accommodate color filters and pagination parameters
- Prefetched `colors` in item queries to optimize performance
This commit is contained in:
2026-05-26 03:57:38 +02:00
parent 56af404dc9
commit 4a7f520037
3 changed files with 60 additions and 7 deletions

View File

@@ -1,3 +1,18 @@
<main class="item-list">
{% include "_fragments/item-grid.html" with items=items empty_message="В этой категории пока нет товаров." %}
{% include "_fragments/item-grid.html" with items=page_obj empty_message="В этой категории пока нет товаров." %}
{% if paginator.num_pages > 1 %}
<nav class="catalog-pagination">
{% if page_obj.has_previous %}
<a href="?{{ pagination_query_string }}&page={{ page_obj.previous_page_number }}" class="catalog-pagination__btn">&laquo;</a>
{% endif %}
{% for i in paginator.page_range %}
<a href="?{{ pagination_query_string }}&page={{ i }}"
class="catalog-pagination__btn {% if i == page_obj.number %}active{% endif %}">{{ i }}</a>
{% endfor %}
{% if page_obj.has_next %}
<a href="?{{ pagination_query_string }}&page={{ page_obj.next_page_number }}" class="catalog-pagination__btn">&raquo;</a>
{% endif %}
</nav>
{% endif %}
</main>