Problem Description:
After the existing model, modify, want to re-modeling, so the migrations folder in addition to other __init__.py files are deleted, perform the following steps python manage.py makemigrations again confirm the successful execution python manage .py migrate, suggesting No migrations to apply. represents a look ignorant force. Modified again, specify the table name, try again, found the problem persists, it represents two faces ignorant force
investigation process
python manage.py dbshell into the database inside to see if the table already exists
Result: The table does not exist
check the file migrations
result: file no problem
Baidu google variety of search, trying everything, try a variety of
solutions
python manage.py dbshell into the database, execute the WHERE App = django_migrations from the delete 'your_appname';
Python manage.py makemigrations (if migrations files were not removed, this step may not be performed )
Python manage.py the migrate Well, we're done
cause analysis
view django_migrations table structure
built table statement:
py sqlmigrate user 0002) to view the current sql statement corresponding file migrations. Further, when viewing the sql statement file 0002 by using the commands found, Django user_new will create a new table, and then insert the data in the user table, and then delete the user table, and then rename user_new user. So, when the modified model, do not worry about the original data will be lost.
---------------------
reproduced the original link: https: //blog.csdn.net/qq_25730711/article/details/60327344
django- questions about manage.py migrate invalid
Guess you like
Origin www.cnblogs.com/huagongzi/p/11323006.html
Ranking