[Answer]-Django South datamigration pre_save() uses model's __unicode__()

0👍

I have updated to South 0.7.6 and used solution from the South documentation. Simply added to_python() and get_prep_value() methods to leave slug field as is.

class AutoSlugField(models.CharField):
    def pre_save(self, blog, *args, **kwargs):
        return slugify(unicode(blog))

    def to_python(self, value):
        return value

    def get_prep_value(self, value):
        return value
👤niekas

1👍

South does nothing but just add column to your table and django has no role to play in it. So when you run migration, django model save method is not called hence no pre-save method gets called. South works on database only, i.e., you can provide attributes such as default value, nullable etc. which can be set at db level. To add slug to existing records in db, create util function which would slugify your field or write a data migration.

👤Arpit

Leave a comment