Updated answer for Django migrations without south plugin:
Like T.T suggested in his answer, my previous answer was for south migration plugin, when Django hasn’t any schema migration features.
Now (works in Django 1.9+):
T.T wrote:
You can try this!
python manage.py makemigrations python manage.py migrate --run-syncdb
Outdated for south migrations plugin
As I can see you done it all in wrong order, to fix it up your should
complete this checklist (I assume you can’t delete sqlite3 database
file to start over):
- Grab any SQLite GUI tool (i.e. http://sqliteadmin.orbmu2k.de/)
- Change your model definition to match database definition (best approach is to comment new fields)
- Delete
migrationsfolder in your model- Delete rows in
south_migrationhistorytable whereapp_namematch your application name (probablyhomework)- Invoke:
./manage.py schemamigration <app_name> --initial- Create tables by
./manage.py migrate <app_name> --fake(--fakewill skip SQL execute because table already exists in your database)- Make changes to your app’s model
- Invoke
./manage.py schemamigration <app_name> --auto- Then apply changes to database:
./manage.py migrate <app_name>Steps 7,8,9 repeat whenever your model needs any changes.