Solutions to django.db.utils.programmingerror:1146

Source: Internet
Author: User



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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.