I am build a business listing website and have a django model that stores and manages notifications. One such notification is supposed to notify people who follow a particular business whenever a product posted on by the business owner is approved.
To achieve this I have a receiver function
@receiver(pre_save, sender=Product)
def create_product_notification(sender, instance, created=False, **kwargs):
if instance.is_verified:
for user in instance.shop.followers.all():
# create notification here
create_notification(receiver=user, doer=instance.shop.owner, verb=f"{instance.shop} added a new product, ( {instance} )", target=instance)
This works when the model is saved after verifying. However, the function is not even called when I run queryset.update(is_verified=True)
from a custom django admin action I have.
Your help is well appreciated?