加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

django.db.utils.NotSupportedError: Renaming the 'app

发布时间:2020-12-15 17:13:55 所属栏目:大数据 来源:网络整理
导读:在测试项目中,数据库: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

在测试项目中,数据库: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类。

解决方法:

文件路径:项目路径appsmigrations006_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',????]


(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读