django 重建一个表

有时候由于添加字段顺序不对,需要对table重建

1. 物理delete table

2.删除model上这个表

3. python manage.py makemigrations rowtable

 执行makemigration  - Delete model ParentSurvey

4.假装删除表,目的是让model与实际table一致

 python manage.py migrate --fake rowtable

5.在model上添加表,并makemigrations

(py3.6env) lxg@lxg-opt:~/98receive/pystudy/generaldb$ python manage.py makemigrations rowtable
Migrations for 'rowtable':
rowtable/migrations/0010_parentsurvey.py
- Create model ParentSurvey

6.migrate ,物理上添加表
(py3.6env) lxg@lxg-opt:~/98receive/pystudy/generaldb$ python manage.py migrate rowtable

原文地址:https://www.cnblogs.com/lxgbky/p/15161171.html