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:
- remove South from my
syncdbto create all the model Tables
- Add South back
syncdbto create the South tables
migrate --faketo 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
migrate, and one of my apps threw the following error:
File "C:\Users\ben\Envs\DH\lib\site-packages\south\orm.py", 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
manage.py syncdb --all manage.py 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!