开发者

Django - Overriding model's delete() method in base class - recursive problem

I have a abstract class which has some common methods for all of my models. I have inherited this class in all my models. Now there is a requirement to send the mail whenever a model is deleted. So I have override the delete() method in my abstract class. This leads to the recursive call of same method because calling the super method.

    super(Model, self).save(*args,开发者_如何学Go **kwargs) 

    class Common(models.Model): 
             #mail logic
             super(type(self), self).delete(*args, **kwargs)        

    class Child(Common)      
             # fields


This is why you must always use the proper type instead of type(self).

super(Common, self).delete(*args, **kwargs)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜