13 lines
546 B
Python
13 lines
546 B
Python
from django.db.models.signals import post_save
|
|
from django.dispatch import receiver
|
|
from .models import Product
|
|
from programmer.tasks import send_new_product_notification
|
|
|
|
|
|
@receiver(post_save, sender=Product)
|
|
def notify_about_new_product(sender, instance, created, **kwargs):
|
|
"""
|
|
Отправляет уведомления подписчикам, когда создаётся и публикуется новый продукт.
|
|
"""
|
|
if created and instance.is_published:
|
|
send_new_product_notification.delay(instance.id) |