attribute: Phillie Casablanca

Changing a model



I forgot to mention this item last time, but here's what you need to do when you change a model:

From the Django FAQ:
http://www.djangoproject.com/documentation/0.96/faq/

If I make changes to a model, how do I update the database?

If you don’t mind clearing data, your project’s manage.py utility has an option to reset the SQL for a particular application:

manage.py reset appname

This drops any tables associated with appname and recreates them.

If you do care about deleting data, you’ll have to execute the ALTER TABLE statements manually in your database. That’s the way we’ve always done it, because dealing with data is a very sensitive operation that we’ve wanted to avoid automating. That said, there’s some work being done to add partially automated database-upgrade functionality.

---
As mentioned, unfortunatly changing an existing model isn't as easy as I'd like it to be. I guess you could aways create a whole new model for any change you want made to the existing... but this still isn't the cleanest way to deal with the issue.


monkut // April 15, 2008 // 7:17 a.m.