There are two models Groups and Students and only one table for Groups of them, the Students table was deleted.
How to make Django recreate the deleted table? If I do makemigrations
it prints "No changes detected".
On admin page when I click on the Students table it throws an exception:
relation "students_students" does not exist
Deleting migration files means losing your history. This historical info is recorded in the django_migrations table in your database. if you delete migration files, you will get dependency errors. So Don't try to lose your history by deleting your migration files.
Another option is to use Django's manage.py command to clear the whole database for us. The command is python manage.py flush . Again, after using this command, we have to delete all the migrations folders and then make the new migrations.
In django 1.7 you can try:
1. Delete your migrations folder 2. In the database: DELETE FROM django_migrations WHERE app = 'app_name'. You could alternatively just truncate this table. 3. python manage.py makemigrations 4. python manage.py migrate --fake
If you are working in django 1.9.5 this is the 100 % solution for this problem:
1. Delete your migrations folder 2. In the database: DELETE FROM django_migrations WHERE app = 'app_name'. You could alternatively just truncate this table. 3. python manage.py makemigrations app_name 4. python manage.py migrate
This works 100% for me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With