Reputation: 11363
I have a legacy database that I'm using in an app in Django. I used the django admin functionality to generate the models.py file from the existing tables.
If I make changes to the models, such as adding a unique_together
constraint to models, are the changes managed by Django, or do I have to somehow apply said model changes to the database?
Upvotes: 2
Views: 435
Reputation: 82450
In order for django to detect changes, you will need to use a third party migration tool called south
. Now, since you've already committed meaning you ran python manage.py syncdb
, you will need to delete the table and start over.
This is how you do it (after you have deleted your table):
pip install south
python manage.py schemamigration --inital <your app name>
python manage.py migrate <your app name>
python manage.py syncdb
<- last time you will need to run it :)Hope this helped.
Upvotes: 3