I have a save override method in my model class, which generates a new slug each 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 logging into the python shell, I see the save method is being invoked.
python manage.py shell
>>> MyModel(column1="test",column2="2015").save()
slug is test-2015
However when I am running a migration, this save override method is not being called. Here's 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 slug is empty, as the save override isn't being called.