微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

django.db.utils.NotSupportedError: Renaming the 'apps_article' table while in a transaction is not supported on SQLite

在测试项目中,数据库sqlite,修改表名时提示错误

django.db.utils.NotSupportedError: Renaming the 'apps_article' table while in a transaction is not supported on sqlite < 3.26 because it would break referential integrity. 
Try adding `atomic = False` to the Migration class.

中文意思:

sqlite不支持在事务中重命名apps_article表,因为它会破坏参照完整性。尝试添加atomic = False到Migration类。

解决方法

文件路径:项目路径\apps\migrations\0006_auto_20190708_1144.py

from django.db import migrations


class Migration(migrations.Migration):
    atomic = False  # 添加atomic
    dependencies = [
        ('apps', '0005_auto_20190701_2022'),    ]

    operations = [
        migrations.AlterModelOptions(
            name='article',            options={'ordering': ['-pub_date'], 'verbose_name': '文章表', 'verbose_name_plural': '文章表'},        ),        migrations.AlterModelTable(
            name='article',            table='article',    ]


版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐