Cannot add foreign key constraint

django orm做migration时报错“Cannot add foreign key constraint”,执行python manage.py sqlmigrate查看具体的sql

执行:SHOW ENGINE INNODB STATUS;

查看market表中id字段的定义

待添加管理的字段的定义

原来market表中id多带了unsigned,修改之:alter table market modify column id INTEGER AUTO_INCREMENT NOT NULL ;

问题解决

你可能感兴趣的:(Cannot add foreign key constraint)