Six Pearls Designs

Django and South Migrations on a new project

2013 December 11

I was working on a Django project recently that used South and a few other re-usable apps with South dependencies. I had run into a problem before where the re-usable apps wouldn't create tables with syncdb. My solution before was:

  1. remove South from my INSTALLED_APPS list
  2. run syncdb to create all the model Tables
  3. Add South back
  4. re-run syncdb to create the South tables
  5. Run migrate --fake to tell South the model tables are up to date

On this project I trying to load fixtures to pre-populate the database, so I thought I should do things the "right" way. I tried running syncdb and migrate, and one of my apps threw the following error:

  File "C:\Users\ben\Envs\DH\lib\site-packages\south\", line 231, in eval_in_context
    raise ValueError("Cannot import the required field '%s'" % value)
ValueError: Cannot import the required field 'tagging.fields.TagField'

The migration required a package (tagging) that they had later dropped. As it turns out, there is a (as far as I can tell, undocumented) option that solves the issue syncdb --all migrate --fake

The first line seems to tell the management command to ignore the fact that there are south migrations and build all the tables. The second line, which is actually well documented, records the South migrations without actually modifying the database. I only found the syncdb --all option in discussions trouble-shooting only slightly-related-looking problems when I decided to try it out. Actually, a lot of the discussions/trouble-shooting seemed to assume trying the --all flag. But even looking for documentation on the flag from South or Django, I'm not finding so I thought it would be helpful to throw up on the blog. If you need help getting around un-synced models with Django and South, this will probably help!