zoukankan      html  css  js  c++  java
  • 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 就好啦
  • 相关阅读:
    JAVA闰年测试与解决非法输入
    Junit介绍与实现
    等价类划分方法的应用
    使用Visual Studio 2013进行UI自动化测试
    简谈软件测试
    【Software Project Management】Quizs
    White box testing
    peer review
    闰年问题
    热烈庆贺清明小长假的到来
  • 原文地址:https://www.cnblogs.com/erhangboke/p/11660133.html
Copyright © 2011-2022 走看看