Friday, July 5, 2013

How to create my first migration script using south

How to created my first migration script using south

1)
Create Migration script for create tables for models
#python manage.py schemamigration myapp --initial

2)
Execute Migration Script
#python manage.py migrate myapp

3)
Check status
#python manage.py migrate --list

4)
Create a new Migration script "000x_add_content_type.py" for add entry to contenttype for new model
#python manage.py datamigration app_settings add_content_type --freeze=contenttypes --freeze=auth

5)
Edit the Migration script "000x_add_content_type.py" and override forward() method.
I added following line method forward()
ct, created = orm['contenttypes.ContentType'].objects.get_or_create(model='ielabexcludeyear', app_label='app_settings')

6)
Execute Migration Script
#python manage.py migrate myapp

7)
Add Permissions for new app and models
The command "add_group_permissions" is not the part of "south" tool
The command "add_group_permissions" is created using django' custom-management-commands feature.
https://docs.djangoproject.com/en/dev/howto/custom-management-commands/
#python manage.py add_group_permissions

8)
http://fosshelp.blogspot.in/2013/07/how-to-use-django-south.html

No comments:

Post a Comment