signals.py
from django.db.models.signals import post_save
from app.models import Book
def send_update(sender, instance, created, **kwargs):
if instance.author_name:
message = "Book is updated"
subject = "Updates"
send_mail(subject, message, your_email,
[instance.email,])
post_save.connect(send_update, sender=Book)
Register the signals by importing it in the app's __init__.py
file. This will allow to import models
from signals.py
.
__init__.py
import signals