Manage migrations in Django

March 26, 2011 | By Regaz | Filed in: Uncategorized.

If you want to manage your migrations in Django in a similar way than
is done on Rails you will need to install and use the South framework for Django.

I will resume here the easiest way to installing it :)

$ easy_install Sout

Once this ha been correctly accomplished you will follow to setup you application
for correctly using South.

I suppose you already are in a Django project and you have make a new application
than I will suppose memo-ridiculously to call southpark :)

$ python startapp southpark

Now, for permit use of South inside to your application you need to insert both
‘southpark’ and ‘South’ in
your for example like that:


After that you will provide to make the South migration history table for the first time by executing a syncdb:

$ python syncdb

than will give you a response from terminal something like that:

Creating table south_migrationhistory
Not synced (use migrations):
(use ./ migrate to migrate these)

Next we need to create an initial migration for South by:

$ python schemamigration YOURPROJECT.southpark --initial

You will get a terminal’s reply than will resemble something like below:

+ Added model southpark.Booking
+ Added unique constraint for ['booking_date', 'booking_number'] on southpark.Bo
+ Added model southpark.Address
Created You can now apply this migration with: ./ migr
ate YOURPROJECT.southpark

Do Not Forget to Take a Look…

Bloogger Blogger, Google Blogger, Google Google

Feel Better on Debian Linux

Now we need to give control to South on our application by executing:

$ python migrate

Than will show a terminal response resembling to this beneath:

project.customer 0001 --fake
- Soft matched migration 0001 to 0001_initial.
Running migrations for southpark:
- Migrating forwards to 0001_initial.

All the steps above where necessary for to setup South for the first time on your application and after every time you will need to make a new migration a database’s change you will provide to:
1) prepare your migration:

$ python schemamigration project.customer --auto

2) execute this one:

$ python migrate project.customer

All my best…
Push hard & Be strong! :)

Tags: , , , ,