I am using Django to build a website with MySQL. Now as I am learning so I need to change the Model very often so I want that all tables get cleared and new table get created.
But syncdb doesn’t touch existing tables. Is there any better way to handle this problem?
If you don’t care about data:
Best way would be to drop the database and run
syncdbagain. Or you can run:For Django >= 1.5
For Django < 1.5
(you can add
--no-inputto the end of the command for it to skip the interactive prompt.)If you do care about data:
From the docs:
https://docs.djangoproject.com/en/dev/ref/django-admin/
Reference: FAQ – https://docs.djangoproject.com/en/dev/faq/models/#if-i-make-changes-to-a-model-how-do-i-update-the-database
People also recommend South ( http://south.aeracode.org/docs/about.html#key-features ), but I haven’t tried it.