Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add pagination
michal10f3acc2b219
diff --git a/requirements.in b/requirements.inindex 272a76f747..c4193b0df5 100644--- a/requirements.in+++ b/requirements.in@@ -7,6 +7,7 @@ dj_email_url>=0.0.4django-bootstrap3>=8.2.1django-cache-url>=1.0.0django-countries>=4.1+django-filter==1.0.4django-mptt>=0.7.1django-payments>=0.11.0django-prices>=0.4.11diff --git a/saleor/product/views.py b/saleor/product/views.pyindex db0ed1dbb6..b4e5a75e1d 100644--- a/saleor/product/views.py+++ b/saleor/product/views.py@@ -9,7 +9,8 @@ from django.shortcuts import get_object_or_404, redirectfrom django.template.response import TemplateResponsefrom ..cart.utils import set_cart_cookie-from ..core.utils import serialize_decimal+from ..core.utils import serialize_decimal, get_paginator_items+from ..settings import PAGINATE_BYfrom .filters import ProductFilterfrom .models import Categoryfrom .utils import (products_with_details, products_for_cart,@@ -116,14 +117,14 @@ def category_index(request, path, category_id):products = products_with_details(user=request.user).filter(categories__name=category)product_filter = ProductFilter(request.GET, queryset=products)-products = [(product, get_availability(product, request.discounts, request.currency))for product in product_filter.qs]-if actual_path != path:return redirect('product:category', permanent=True, path=actual_path,category_id=category_id)+ products = get_paginator_items(+ products, PAGINATE_BY, request.GET.get('page'))context = {'category': category, 'products': products,'filter': product_filter}return TemplateResponse(request, 'category/index.html', context)