Search code examples
djangodjango-south

Setting up an existing Django + South project instance


I've been working with django + south for a while and still haven't nailed this issue down.

Take an existing project, with existing apps and existing migrations that have been added over time. Now suppose you want to deploy it to a new dev machine (for example) with a clean database.

What would be the process?

Remember the that settings at this point contains:

INSTALLED_APPS = (
    'django.contrib.auth',
    # ...
    'south',
    'myapp1',
    'myapp2',
)

So on one hand, if you try to run the migrations, you won't get anything since no database exists yet. But if you try to syncdb it'll simply sync without the south migrations.

So what's the right process to do this?


Solution

  • How about syncdb, and then migrate?

    $ python manage.py syncdb
    $ python manage.py migrate
    

    South's patched syncdb management command tells you as much at the end:

    $ python manage.py syncdb
    Syncing...
    Creating tables ...
    Installing custom SQL ...
    Installing indexes ...
    No fixtures found.
    
    Synced:
     > django.contrib.auth
    
    Not synced (use migrations):
     - myapp1
     - myapp2
    (use ./manage.py migrate to migrate these)