Skip to content

Commit b18f61e

Browse files
bug: sloved get_recommneded_products func getting exception
1 parent d12439f commit b18f61e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

shop/serializers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ def get_recommended_products(self, obj):
140140
recommended_products = [product.product_id for product in
141141
recommender.suggest_products_for([obj], max_results=5)]
142142
suggested_products = (
143-
Product.objects.filter(
144-
Q(category=obj.category) | Q(
145-
tags__in=obj.tags.all() | Q(product_id__in=recommended_products)
146-
)).exclude(product_id=obj.product_id).distinct())[:10]
143+
Product.objects.filter(
144+
Q(category=obj.category) |
145+
Q(tags__in=obj.tags.all()) |
146+
Q(product_id__in=recommended_products)
147+
).exclude(product_id=obj.product_id).distinct()[:10]
148+
)
147149
return ProductSerializer(suggested_products, many=True, context=self.context).data
148150

149151
class Meta(ProductSerializer.Meta):

0 commit comments

Comments
 (0)