IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constrai nt fails (`mxonline

来源:互联网 发布:淘宝网如何绑定银行卡 编辑:程序博客网 时间:2024/06/04 18:49
IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`mxonline`.`django_admin_log`, CONSTRAINT `django_admin_log_user_id_c564eba6_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))')

解决方案

settings.py

增加

'OPTIONS': {        "init_command": "SET foreign_key_checks = 0;",        }

修改成

# Database# https://docs.djangoproject.com/en/1.9/ref/settings/#databasesDATABASES = {    'default': {        'ENGINE': 'django.db.backends.mysql',        'NAME': 'mxonline',        'USER': 'root',        'PASSWORD': 'root',        'HOST': '127.0.0.1',        'OPTIONS': {        "init_command": "SET foreign_key_checks = 0;",        }    }}
阅读全文
0 0
原创粉丝点击