Setting up a brand new project and no database
create your database
add south to installed apps
run syncdb, this will add the django and south tables to the database
add your apps
for each app run
python manage.py schemamigration app_name --initial
this will create the initial migration files for your appthen run south migrate
python manage.py migrate app_name
this will add the tables to the database.
Setting up a legacy project and database
add south to installed apps
run syncdb, this will add the south tables to the database
for each of your apps run
python manage.py schemamigration app_name --initial
This will create your initial migrationsfor each of your apps run
python manage.py migrate app_name 0001 --fake
, this will fake out south, it won't do anything to the database for those models, it will just add records to the south_migrationhistory table so that the next time you want to create a migration, you are all set.
Setting up a legacy project and no database
create database
add south to installed apps
for each of your apps run
python manage.py schemamigration app_name --initial
This will create your initial migrationsrun syncdb, this will add any apps that don't have migrations to the database.
then run south migrate
python manage.py migrate
this will run all migrations for your apps.
转载于:https://blog.51cto.com/ahwind/1373980