Skip to content

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

Add prefetches

Pacu23444ad963556
diff --git a/saleor/checkout/views/__init__.py b/saleor/checkout/views/__init__.py
index e69e100b73..7bc8ea8f51 100644
--- a/saleor/checkout/views/__init__.py
+++ b/saleor/checkout/views/__init__.py
@@ -112,7 +112,9 @@ def cart_index(request, cart):
lines = lines.prefetch_related(
'variant__translations', 'variant__product__translations',
'variant__product__images',
- 'variant__product__product_type__variant_attributes__translations')
+ 'variant__product__product_type__variant_attributes__translations',
+ 'variant__images',
+ 'variant__product__product_type__variant_attributes')
for line in lines:
initial = {'quantity': line.quantity}
form = ReplaceCartLineForm(
diff --git a/saleor/order/views.py b/saleor/order/views.py
index 4b0be4e4b6..8a482a09c6 100644
--- a/saleor/order/views.py
+++ b/saleor/order/views.py
@@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
def details(request, token):
orders = Order.objects.confirmed().prefetch_related(
- 'lines__variant__product__images', 'fulfillments',
+ 'lines__variant__images', 'lines__variant__product__images',
'fulfillments__lines', 'fulfillments__lines__order_line')
orders = orders.select_related(
'billing_address', 'shipping_address', 'user')
@@ -50,7 +50,8 @@ def details(request, token):
def payment(request, token):
orders = Order.objects.confirmed().filter(billing_address__isnull=False)
- orders = orders.prefetch_related('lines__variant__product__images')
+ orders = orders.prefetch_related(
+ 'lines__variant__images', 'lines__variant__product__images')
orders = orders.select_related(
'billing_address', 'shipping_address', 'user')
order = get_object_or_404(orders, token=token)
diff --git a/tests/test_product_tags.py b/tests/test_product_tags.py
index cc58da614d..7a02836dca 100644
--- a/tests/test_product_tags.py
+++ b/tests/test_product_tags.py
@@ -4,7 +4,7 @@ from django.contrib.staticfiles.templatetags.staticfiles import static
from django.test import override_settings
from saleor.product.templatetags.product_images import (
- choose_placeholder, get_thumbnail, get_thumbnail)
+ choose_placeholder, get_thumbnail)
@override_settings(