Friday, December 14, 2012

DJango Python 101

DJango commands cheatsheet


How to start server:
./manage.py runserver

How to create new app
./manage.py startapp newappname

Database stuff
How to create database from models (Use South instead)
./manage.py syncdb

How to use South
http://south.readthedocs.org/en/latest/commands.html

For existing app
you will need to convert into South supported app first.
./manage.py convert_to_south myappname

For new apps
Create db (Similar to syncdb command)
./manage.py schemamigration myappname --initial

Update db with schema changes
./manage.py schemamigration myappname --auto

These commands generates migration scripts only.
Run this command for changes to take effect in db
./manage.py migrate myappname

1 comment: