I create base model and inherit that in all of my models. This is my BaseModel:
class BaseModel(models.Model): create_date = models.DateTimeField(auto_now_add=True) update_date = models.DateTimeField(auto_now=True) created_by = models.ForeignKey('UserManager.User', default=1, on_delete=models.SET_DEFAULT,related_name='created_%(class)ss') updated_by = models.ForeignKey('UserManager.User', default=1, on_delete=models.SET_DEFAULT,related_name='updated_%(class)ss') class Meta: abstract = True ordering = ['create_date'] def save(self, *args, **kwargs): self.user = kwargs.pop('user', None) if self.user: if self.user.pk is None: self.created_by = self.user self.updated_by = self.user super(BaseModel, self).save(*args, **kwargs) Now, I want to add some operations to save method of one of child models like this:
class Child(BaseModel): # Some fields go here. def save(self, *args, **kwargs): # Some operations must run here. But save method of child model does n't run anymore!
How can I use save method of child model with save method of abastract=True model?
django-3.0if your question is specifically about that version and the answers wouldn't be applicable for other (earlier or later) Django versions, for instance, version migration problems.