Execute commands after setting database-related things in models
Python manage.py makemigrations
No errors here
Execute again
Python manage.py Migrate
An error occurred
Error messages are long, look up and find the source of the error
Django.db.utils.ProgrammingError: (1146, "Table" test.model_stude
NT ' doesn ' t exist ")
The reason for this mistake is that I've deleted a table in MySQL, and Django wants to make a field change and find out that the table is gone.
The way to eliminate recurrence is to modify the table by using the settings in Django, not to delete the table yourself from MySQL
The solution is as follows:
1. Delete the tables you have created in MySQL (except for the Django auto-generated tables, which will be deleted from the table you set for your business needs)
2. Find your own model, a folder named "Migrations" in the directory, enter this folder
3. Keep the Pycache folder and the init file, the rest of the delete
4. Locate your database in MySQL and find the table named "Django_migrations" in the table
5. Delete all data in the table
6. Re-execute two commands
Python manage.py makemigrations python manage.py migrate Model
So the database is normal!
Solutions to django.db.utils.programmingerror:1146