class M_Post(models.Model):
''''
CODE
''''
class M_File(models.Model):
....
CODE
....
class M_Post_File(models.Model):
post = models.ForeignKey(M_Post,on_delete=models.CASCADE)
file = models.ForeignKey(M_File,on_delete=models.CASCADE,null=True)
错误:
django.db.utils.NotSupportedError:SQLite 不支持在事务中重命名“posts_file”表,因为它会破坏引用完整性。尝试将 atomic = False
添加到 Migration 类。
如何解决这个错误
最佳答案
转到相关的迁移文件(在 makemigrations 命令后自动在 migrations 目录中创建)并将 atomic = False
添加到迁移类。 迁移(migrations.Migration):
。然后您可以迁移更改。
示例代码:
# Generated by Django 2.1.14 on 2019-12-02 07:07
from django.db import migrations, models
class Migration(migrations.Migration):
atomic = False # **<<< HERE**
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='ebayLog',
fields=[
关于sqlite 中的 django.db.utils.NotSupportedError 为什么在 sqlite 中不受支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48549068/