Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Reduce queries in checkout view
Krzysztof Wolski32151e061664
diff --git a/saleor/checkout/core.py b/saleor/checkout/core.pyindex 6d2df43387..71aed9cdda 100644--- a/saleor/checkout/core.py+++ b/saleor/checkout/core.py@@ -1,19 +1,20 @@from __future__ import unicode_literals+from functools import wrapsfrom django.conf import settingsfrom django.db import transactionfrom django.forms.models import model_to_dictfrom django.utils.encoding import smart_text-from prices import Price, FixedDiscount+from prices import FixedDiscount, Pricefrom ..cart.models import Cartfrom ..cart.utils import get_or_empty_db_cartfrom ..core import analytics-from ..discount.models import Voucher, NotApplicable+from ..discount.models import NotApplicable, Voucherfrom ..order.models import Orderfrom ..order.utils import add_items_to_delivery_group-from ..shipping.models import ShippingMethodCountry, ANY_COUNTRY+from ..shipping.models import ANY_COUNTRY, ShippingMethodCountryfrom ..userprofile.models import Addressfrom ..userprofile.utils import store_user_address@@ -145,7 +146,8 @@ class Checkout(object):address = self._get_address_from_storage('billing_address')if address is not None:return address- elif self.user.is_authenticated() and self.user.default_billing_address:+ elif (self.user.is_authenticated() and+ self.user.default_billing_address):return self.user.default_billing_addresselif self.shipping_address:return self.shipping_address@@ -331,8 +333,7 @@ class Checkout(object):def load_checkout(view):@wraps(view)- @get_or_empty_db_cart(Cart.objects.all().prefetch_related(- 'lines__variant__product'))+ @get_or_empty_db_cart(Cart.objects.for_display())def func(request, cart):try:session_data = request.session[STORAGE_SESSION_KEY]