Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Hide paginator when products fit in one page

dominik-zeglen534b31d877dd
diff --git a/saleor/product/views.py b/saleor/product/views.py
index 4013ffcf69..f52b33e794 100644
--- a/saleor/product/views.py
+++ b/saleor/product/views.py
@@ -129,5 +129,6 @@ def category_index(request, path, category_id):
context = {'category': category, 'filter': product_filter,
'products': products_and_availability,
'products_paginated': products_paginated,
- 'sort_by_choices': [choice[1] for choice in SORT_BY_FIELDS]}
+ 'sort_by_choices': [choice[1] for choice in SORT_BY_FIELDS],
+ 'show_pagination': True if len(products) > PAGINATE_BY else False}
return TemplateResponse(request, 'category/index.html', context)
diff --git a/templates/category/index.html b/templates/category/index.html
index 339b053530..8313f2bacc 100644
--- a/templates/category/index.html
+++ b/templates/category/index.html
@@ -160,7 +160,9 @@
</div>
<div class="row">
<div class="m-auto">
- {% bootstrap_pagination products_paginated extra=request.GET.urlencode %}
+ {% if show_pagination %}
+ {% bootstrap_pagination products_paginated extra=request.GET.urlencode %}
+ {% endif %}
</div>
</div>
</div>