Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add pagination to recent order view
akjanikb958f9992602
diff --git a/saleor/userprofile/views.py b/saleor/userprofile/views.pyindex ded93a1f2b..2bbe7783d0 100755--- a/saleor/userprofile/views.py+++ b/saleor/userprofile/views.py@@ -6,15 +6,17 @@ from django.template.response import TemplateResponsefrom django.urls import reversefrom django.utils.translation import pgettext+from ..core.utils import get_paginator_itemsfrom .forms import (ChangePasswordForm, get_address_form, logout_on_password_change)-@login_requireddef details(request):password_form = get_or_process_password_form(request)+ orders = request.user.orders.prefetch_related('groups__lines')+ orders_paginated = get_paginator_items(orders, 5, request.GET.get('page'))ctx = {'addresses': request.user.addresses.all(),- 'orders': request.user.orders.prefetch_related('groups__lines'),+ 'orders': orders_paginated,'change_password_form': password_form}return TemplateResponse(request, 'userprofile/details.html', ctx)diff --git a/templates/userprofile/details.html b/templates/userprofile/details.htmlindex f86d40752a..0c59a66efb 100644--- a/templates/userprofile/details.html+++ b/templates/userprofile/details.html@@ -5,6 +5,7 @@{% load discount_amount_for from prices %}{% load status %}{% load bootstrap_form from bootstrap3 %}+{% load bootstrap_pagination from bootstrap3 %}{% block title %}{% trans "Your profile" context "User profile page title" %} — {{ block.super }}{% endblock %}@@ -85,6 +86,13 @@</div></div>{% endfor %}+ <div class="row">+ <div class="m-auto">+ {% if orders.has_other_pages %}+ {% bootstrap_pagination orders extra=request.GET.urlencode %}+ {% endif %}+ </div>+ </div>{% else %}<h3 class="text-sm-center userprofile__orders-empty">{% trans "There are not any completed orders yet." context "No recent orders text" %}