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