diff --git a/core/tasks.py b/core/tasks.py index 90f0b808..21052e19 100644 --- a/core/tasks.py +++ b/core/tasks.py @@ -209,7 +209,8 @@ def process_promotions() -> tuple[bool, str]: product = eligible_products.order_by("?").first() selected_products.append(product) - promotion = Promotion.objects.create(name=promotion_name, discount_percent=discount_percent, is_active=True) + promotion = Promotion.objects.update_or_create(name=promotion_name, + defaults={"discount_percent": discount_percent, "is_active": True}) promotion.products.set(selected_products)