I'm trying to override the save method of one of my models. Within that save method I would like to use another method of the model, like this:
class MyModel(models.Model): name = models.CharField(max_length=255) def do_something(self): pass def save(self,*args, **kwargs): self.do_something() super(MyModel, self).save(*args, **kwargs) This doesn't work because when django executes the save, the object is a generic ModelBase class and not my subclass of ModeBase. So I get:
unbound method do_something() must be called with MyModel instance as first argument (got ModelBase instance instead) What is the right way to do this?
super(MyModel, self).save(*args, **kwargs)before you callself.do_something()? So just switch the two so that the object will get created first.