Reputation: 485
If I go to the Django admin page and delete a user, I want it to run some code before/after it deletes the user. I know about overriding models' delete()
methods, but I'm not sure how to apply it to a built-in model. Also, I'd like to be able to do it without 'subclassing' the User
model and creating a (for instance) MyUser
model.
Is there any way to accomplish this?
Upvotes: 0
Views: 1189
Reputation: 2457
yes, you can listen to the django pre_delete and post_delete signal: here is the doc link: http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.pre_delete http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.post_delete
Upvotes: 1