django models 操作数据库遇到相关问题 Cannot add foreign key constrain
2018-01-03 11:01
1266 查看
错误信息:
1、django.db.utils.IntegrityError: (1215, u'Cannot add foreign key constraint')
2、RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.
3、migrate时后面加auth,报错django.db.utils.ProgrammingError: (1146, u"Table '**.django_site' doesn't exist")
解决办法:
1、删除掉本地migrations文件夹,重新migrations和migrate
2、注释
1、django.db.utils.IntegrityError: (1215, u'Cannot add foreign key constraint')
2、RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.
3、migrate时后面加auth,报错django.db.utils.ProgrammingError: (1146, u"Table '**.django_site' doesn't exist")
解决办法:
1、删除掉本地migrations文件夹,重新migrations和migrate
2、注释
INSTALLED_APPS下面的home_application(app名称).然后migrations和migrate,之后把home_applications解注释,
再migrations 后面加上 home_application,然后migrate。解决。
相关文章推荐
- 解决1452- Cannot add or update a child rowa foreign key constraint fails问题
- 刷新数据库总是报错:不能增加或者更新约束, Cannot add or update a child row: a foreign key constraint fails
- 数据库建表的时候报 “1215 Cannot add foreign key constraint”
- django models实际操作中遇到的一些问题
- 异常处理:1215 - Cannot add foreign key constraint
- Cannot add or update a child row: a foreign key constraint fails 无法添加外键
- 无法添加外键约束的原因(cannot add foreign key constraint)
- django数据库错误相关问题
- 1215 - Cannot add foreign key constraint
- Laravel 5.5 迁移报错:General error: 1215 Cannot add foreign key constraint
- 操作sql server 2008数据库遇到的问题和解决方法
- django foreign key 自动加_id问题
- hibernate操作数据库遇到问题的时候检查主键生成策略
- Cannot add foreign key
- django1.8 修改数据库 时间字段 遇到非空问题的解决办法
- 转帖:django下操作数据库的字符问题
- [Mysql] 添加外键失败:Cannot add or update a child row:a foreign key constraint fails
- error:Cannot add or update a child row: a foreign key constraint fails (`xx库`.`xx表`,
- ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails...问题解决
- ERROR 1215 (HY000): Cannot add foreign key constraint