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)
精彩评论