Perform action on model delete

Oct 08, 2013 · by Tim Kamanin

Surprise, surprise, when you want to perform some actions on model delete, overriding delete() method may be not enough, because when you do bulk delete of models via admin interface it won't touch model's delete() method. The way out of it is using signals:

@receiver(post_delete, sender=Model)
def model_delete(sender, instance, **kwargs):
# Do your on delete action here.

Want to get more 🔥 tips like this one?

Subscribe to get notified about new dev tutorials