Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py mig

解决这个问题共有四步,如下:

Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py mig

第一步将数据表删除,但是保留model中定义的数据库代码

Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py mig

第二步打开django_migrations这个表

Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py mig

将要删除的数据表的记录在django_migrations表中删除

Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py mig

 

第三步找到app下的migration文件夹删除数据表记录

Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py mig

第四步  执行python manage.py makemigrations和python manage.py migrate

Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py mig

可以看到重建成功。

上一篇:创建一个Django项目


下一篇:Vue项目中结合Vue-layer实现弹框式编辑功能