1822, "Failed to add the foreign key constraint. Missing index for constraint
问题描述:
首次迁移(之前的表没有关系)后给表添加了关系后再次迁移报错信息:django.db.utils.OperationalError: 1822, "Failed to add the foreign key constraint. Missing index for constraint
解决:
1.删除之前所有的迁移记录, 2.重新生成迁移文件迁移 3.成功
总结:
关系表要在开始就创建好,不能中途再添加后迁移。