It’s accidental to delete a table when performing some actions or on purpose to get rid of cluster. Django has a good in-build engine that can manage the changes in models and your database synced but if you happen to drop a migrated table you will end up with Django : Table doesn't exist
. Here’s how you can fix it.
- Drop tables ( you most probably completed :p )
- Comment-out the model in
models.py
and other locations where the model is induced, else System-checks will fail - if django version >= 1.7 for older see below
python manage.py makemigrations python manage.py migrate --fake
- comment-in your model in
models.py
- Run
makemigrations
andmigrate
again without using--fake
You are back on track.
Note: This does not bring back the data lost when you dropped the table, it recreates the database table and allows further use of application
If you have django version less than 1.7 use schemamigration
to get the magic:
python manage.py schemamigration --auto
python manage.py migrate someapp --fake