Search code examples
pythondjangodjango-south

How do I specify slugifying code in this South migration?


I have a model like:

class Thing(models.Model):
    title = models.CharField(_('Title'), max_length=255)

I want to add this NOT NULL field:

slug = models.SlugField(_('Slug'), max_length=255)

When I run "python manage.py schemamigration things --auto", I get prompted to enter Python code for my one-off default value.

What should I enter here in order to lowercase and slugify the existing titles? And is there anything else that I have to do with the migration, before running 'migrate'?


Solution

  • i'd probably leave it blank in the migration, and instead follow it with a data migration creating the slugs there with some code