South will handle schema migrations for you: http://south.aeracode.org/
This tutorial is a good place to start and covers the basic set-up:http://south.aeracode.org/docs/tutorial/part1.html
Basically, you want to revert your changes so your model matches your
database, install south and configure your app to use it, then convert your
models to use south by typing:
python manage.py schemamigration [appname] --initial
This creates migration files which are stored in [appname]/migrations/
You can then apply these migrations using this command:
python manage.py migrate [appname]
Note that you need to do this for each app in your project. When you change
the model and want to update the database, you can create migration files
python manage.py schemamigration [appname] --auto
Then just apply them as you did with the initial migration.
Some best practices for avoiding issues with South:
- If your model has a NOT NULL field then it should always have a
default. That way South will know what value to fill in when it creates the
- If you are changing a pre-existing model field drastically and don't
care about losing data, I find it most convenient to remove the field,
migrate the schema, then add the field again with the new specification .
This way you will avoid conflicts with any existing constraints. Note that
to preserve the data you'll need to create a (more complicated) data
Hope this helps.
On Thursday, 7 June 2012 14:05:13 UTC-4, Surgemcgee wrote:
Hey Gang, is there a way to update the database with a syncdb or
other command after a model has been changed? I added a field
the the model after the syncdb.
Bust0ut, Surgemcgee: Systems Engineer ---
"Bringing entertainment to Unix"
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-TIpt70lWX4J.
To post to this group, send email to firstname.lastname@example.org.
To unsubscribe from this group, send email to email@example.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.