开发者

Modify Django user delete method?

If I go to the Django ad开发者_JAVA技巧min 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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜