瀏覽代碼

Speedup Range.product_queryset(): exlude Products without parent from join (#4222)

master
Gunther Waidacher 1 年之前
父節點
當前提交
8c04b7d6af
No account linked to committer's email address
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6
    4
      src/oscar/apps/offer/abstract_models.py

+ 6
- 4
src/oscar/apps/offer/abstract_models.py 查看文件

@@ -1134,10 +1134,12 @@ class AbstractRange(models.Model):
1134 1134
                 self.included_categories.values("id")
1135 1135
             )
1136 1136
             _filter |= Q(categories__in=expanded_range_categories)
1137
-            # extend filter for parent categories
1138
-            if Product.objects.filter(
1139
-                parent__categories__in=expanded_range_categories
1140
-            ).exists():
1137
+            # extend filter for parent categories, exclude parent = None
1138
+            if (
1139
+                Product.objects.exclude(parent=None)
1140
+                .filter(parent__categories__in=expanded_range_categories)
1141
+                .exists()
1142
+            ):
1141 1143
                 _filter |= Q(parent__categories__in=expanded_range_categories)
1142 1144
 
1143 1145
         qs = Product.objects.filter(_filter, ~Q(excludes=self))

Loading…
取消
儲存