Perform action on model delete

08 Oct · by Tim Kamanin · 1 min read

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.

Comments

Required for comment verification