Django修改数据库时出错 django.db.utils.OperationalError: (1091, "Can't DROP 'content'; check that column/key exists")

报错信息:

django.db.utils.OperationalError: (1091, "Can't DROP 'content'; check that column/key exists")

可能数据库中的字段结构已经完成了此字段的修改但是在

   python manage.py makemigrations 新生成的migrations/0002_auto_20191011_2104.py文件中  可能还会有删除字段的操作

查看一下该文件:

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('autotest', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='configfile',
name='content',
),
migrations.RemoveField(
model_name='flow',
name='content',
),
migrations.RemoveField(
model_name='node',
name='content',
),
]
果然有删除操作
问题解决:
注释该内容
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('autotest', '0001_initial'),
]

operations = [
# migrations.RemoveField(
# model_name='configfile',
# name='content',
# ),
# migrations.RemoveField(
# model_name='flow',
# name='content',
# ),
# migrations.RemoveField(
# model_name='node',
# name='content',
# ),
]

重新执行python manage.py migrate 就好啦

 

posted @ 2019-10-12 10:43  二航  阅读(6598)  评论(0编辑  收藏  举报