Is the model save () method called when using loaddata for fixtures?

I am trying to create an automatic pool for a model whenever it is empty, from another field. This is the code:

class Position(RichText): name = models.CharField(max_length=200) slug = models.SlugField(null=True) def position_description(self): return self.content def __unicode__(self): return self.name def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(self.name) super(Position, self).save(*args, **kwargs) 

When I load the starters with loaddata, it seems that the save() method never starts. Is this normal behavior? How can I catch fixtures too?

+2
source share
1 answer

This is normal behavior, from the documentation :

When archiving files are processed, the data is stored in the database as it is. Certain models save methods and pre_save signals are not called

.

+2
source

Source: https://habr.com/ru/post/899985/


All Articles