I have a persistence override method in my model class that generates a new slug every time an object is saved.
def save(self, *args, **kwargs):
if self.column2:
self.slug = slugify(self.column1 + " " + self.column2)
else:
self.slug = slugify(self.column1)
print slug
super(MyModel, self).save(*args, **kwargs)
When I try to create a new object by going into the python shell, I see that the save method is being called.
python manage.py shell
>>> MyModel(column1="test",column2="2015").save()
slug is test-2015
However, when I do the migration, this save override method is not called. Here is part of my migration script ..
...
def add_myModel_details(apps, schema_editor):
x = apps.get_model("myapp","myModel")
MyModel(column1 = "test", column2="2015" ).save()
.....
The pool is empty because save overrides are not called.
source
share