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 就好啦
原参考链接:https://www.cnblogs.com/erhangboke/p/11660133.html
本文来自博客园,作者:super_ip,转载请注明原文链接:https://www.cnblogs.com/superip/p/17460049.html