sium_hossain
Posted on August 11, 2022
There are seven built-in signals in Django -
pre_save
: Signal sent before model save()
method is called.
post_save
: Signal sent after model save()
method is called.
pre_delete
: Signal sent before model delete()
method is called.
post_delete
: Signal sent after model delete()
method is called.
m2m_changed
: Signal sent when a ManyToMany
field is changed
request_started
: Signal sent when HTTP
request start.
request_finished
: Signal sent when HTTP
request finished.
from django.dispatch import receiver
from django.db.models.signals import pre_save
@receiver(pre_save, sender=User)
def pre_save_user(sender, instance, created, **kwargs):
if created:
#your logic
💖 💪 🙅 🚩
sium_hossain
Posted on August 11, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.