django 创建mysql失败_创建表时出现Django MySQL错误

我正在用MySQL数据库构建一个django应用程序。当我第一次运行“python manage.py migrate”时,一些表创建得很好,然后出现一些错误。出现的错误是:django.db.utils.IntegrityError: (1215, 'Cannot add foreign key

constraint')

当我运行这个MySQL命令时-SHOW ENGINE INNODB STATUS\G,

我明白了>&gt2015-02-17 14:33:17 7f10891cf700 Error in foreign key constraint of table movie_store/#sql-4f1_66:

FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`):

Cannot resolve table name close to:

(`id`)

完整的回溯是:Creating tables...

Creating table users

Creating table merchant

Creating table celery_taskmeta

Creating table celery_tasksetmeta

Creating table djcelery_intervalschedule

Creating table djcelery_crontabschedule

Creating table djcelery_periodictasks

Creating table djcelery_periodictask

Creating table djcelery_workerstate

Creating table djcelery_taskstate

Creating table post_office_email

Creating table post_office_log

Creating table post_office_emailtemplate

Creating table post_office_attachment

Running deferred SQL...

Traceback (most recent call last):

File "manage.py", line 10, in

execute_from_command_line(sys.argv)

File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line

utility.execute()

File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv

self.execute(*args, **cmd_options)

File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute

output = self.handle(*args, **options)

File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 173, in handle

created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)

File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 309, in sync_apps

cursor.execute(statement)

File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 80, in execute

return super(CursorDebugWrapper, self).execute(sql, params)

File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute

return self.cursor.execute(sql, params)

File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 95, in __exit__

six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 63, in execute

return self.cursor.execute(sql)

File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 124, in execute

return self.cursor.execute(query, args)

File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute

self.errorhandler(self, exc, value)

File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler

raise errorclass, errorvalue

django.db.utils.IntegrityError: (1215, 'Cannot add foreign key constraint')

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/393510.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Laravel数据库迁移和填充(支持中文)

写在前面 经常我们做项目都团队协作开发,每个人都在自己本地的数据库,如果你曾经出现过让同事手动在数据库结构中添加字段的情况,数据库迁移可以解决你这个问题。 不仅如此,在线上部署的时候,也避免了手动导入数据库或…

leetcode374. 猜数字大小(二分法)

猜数字游戏的规则如下: 每轮游戏,系统都会从 1 到 n 随机选择一个数字。 请你猜选出的是哪个数字。 如果你猜错了,系统会告诉你这个数字比系统选出的数字是大了还是小了。 你可以通过调用一个预先定义好的接口 guess(int num) 来获取猜测结果…

什么情况下你的工作最为成功_如何在没有工作经验的情况下获得技术工作

什么情况下你的工作最为成功by Anthony Sistilli安东尼西斯蒂里(Anthony Sistilli) 如何在没有工作经验的情况下获得技术工作 (How to get a tech job with no previous work experience) I run a free community called the Forge where I help students navigate the world …

jquery批量删除

前台代码 <!doctype html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport"content"widthdevice-width, user-scalableno, initial-scale1.0, maximum-scale1.0, minimum-scale1.0">…

MUI 里js动态添加数字输入框后,增加、减少按钮无效

https://www.cnblogs.com/ssjf/p/10193652.html numbox 的自动初化是在 mui.ready 时完成的mui 页面默认会自动初始化页面中的所有数字输入框&#xff0c;动态构造的 DOM 需要进行手动初始化。比如&#xff1a;您动态创建了一个 ID 为 abc 的数字输入框&#xff0c;需要 mui(#a…

Django——认证系统(Day72)

阅读目录 COOKIE 与 SESSION 用户认证 COOKIE 与 SESSION 概念 cookie不属于http协议范围&#xff0c;由于http协议无法保持状态&#xff0c;但实际情况&#xff0c;我们却又需要“保持状态”&#xff0c;因此cookie就是在这样一个场景下诞生。 cookie的工作原理是&#xff1a;…

description方法

1.description基本概念 NSLog("%", objectA);这会自动调用objectA的description方法来输出ObjectA的描述信息. description方法默认返回对象的描述信息(默认实现是返回类名和对象的内存地址) description方法是基类NSObject 所带的方法,因为其默认实现是返回类名和…

leetcode面试题 10.05. 稀疏数组搜索(二分法)

稀疏数组搜索。有个排好序的字符串数组&#xff0c;其中散布着一些空字符串&#xff0c;编写一种方法&#xff0c;找出给定字符串的位置。 示例1: 输入: words [“at”, “”, “”, “”, “ball”, “”, “”, “car”, “”, “”,“dad”, “”, “”], s “ta” 输出…

laravel框架制作缩略图和水印

1.首先需要使用 composer 在命令行安装最新版本的 intervention/image &#xff1a; composer require intervention/image2.注册服务提供者及别名&#xff08;Laravel 版本 ≤ 5.4&#xff09; 如果你的 laravel 版本小于或等于 5.4&#xff0c;安装后需要注册服务提供者和别…

mysql 模糊查询 tp框架_TP框架中模糊查询实现

TP框架中模糊查询实现$where[g.name] array(like,%.$groupname.%);表达式查询上面的查询条件仅仅是一个简单的相等判断&#xff0c;可以使用查询表达式支持更多的SQL查询语法&#xff0c;查询表达式的使用格式&#xff1a;$map[字段1] array(表达式,查询条件1);$map[字段2] ar…

肉体之爱的解释圣经_可以解释的AI简介,以及我们为什么需要它

肉体之爱的解释圣经by Patrick Ferris帕特里克费里斯(Patrick Ferris) 可以解释的AI简介&#xff0c;以及我们为什么需要它 (An introduction to explainable AI, and why we need it) Neural networks (and all of their subtypes) are increasingly being used to build pro…

Python可变与不可变类型及垃圾回收机制

1. 可变与不可变类型 1.1 可变类型 在id不变的情况下&#xff0c;value可以改变&#xff0c;则称之为可变类型。列表、字典与集合是可变的。 l1 [1,2,3,4,5] print(id(l1)) l1[1] 520 #改变列表元素 print(id(l1)) result&#xff1a; 1700748379208 …

12-1 12 防盗链 访问控制 php解析 代理

2019独角兽企业重金招聘Python工程师标准>>> 12.13 Nginx防盗链 12.14 Nginx访问控制 12.15 Nginx解析php相关配置 12.16 Nginx代理 扩展 502问题汇总 http://ask.apelearn.com/question/9109location优先级 http://blog.lishiming.net/?p10012.13 Nginx防盗链 用来…

leetcode911. 在线选举(二分法)

在选举中&#xff0c;第 i 张票是在时间为 times[i] 时投给 persons[i] 的。 现在&#xff0c;我们想要实现下面的查询函数&#xff1a; TopVotedCandidate.q(int t) 将返回在 t 时刻主导选举的候选人的编号。 在 t 时刻投出的选票也将被计入我们的查询之中。在平局的情况下&…

1-13句子逆序

题目描述 将一个英文语句以单词为单位逆序排放。例如“I am a boy”&#xff0c;逆序排放后为“boy a am I”所有单词之间用一个空格隔开&#xff0c;语句中除了英文字母外&#xff0c;不再包含其他字符 接口说明 /** * 反转句子 * * param sentence 原句子 * return 反转后的…

单例模式实现DB类

创建一个类 class DB_class {//public $name andy;//私有的属性private static $db;//公共的静态方法public static function index(){if (self::$db ! null ){return self::$db;}self::$dbnew DB_class();return self::$db;}//私有的构造方法private function __construct()…

终端定时任务 开始缓冲_如何开始使用终端以提高生产力

终端定时任务 开始缓冲by Luciano Strika通过卢西亚诺斯特里卡(Luciano Strika) 如何开始使用终端以提高生产力 (How to start using the terminal to be more productive) As developers, the terminal can be our second home.作为开发人员&#xff0c;码头可以成为我们的第…

图片预览------photoswipe 使用

photoswipe 使用 预览图片后&#xff0c;需要点击关闭按钮才能关闭&#xff0c;点击图片事件效果是放大图片&#xff0c;和微信的效果不一致&#xff0c;最后改用微信预览图片的接口了&#xff0c;但是例子可以用&#xff0c;记录一下&#xff01;&#xff01; http://www.cnbl…

SSKeychain

Keychain 使用? ---为了实用最大化我觉得我应该直接先说使用&#xff01; 当然是使用第三方库啦&#xff1a;sskeychain 3000星星的库不开玩笑。github地址&#xff1a;https://github.com/soffes/sskeychain 导入完之后首先&#xff0c;编译一下有无错。 如果是自己手动导入&…

shell高级-----正则表达式

正则表达式概述 正则表达式是一种定义的规则&#xff0c;Linux工具可以用它来过滤文本。 基础正则表达式 纯文本 [rootnode1 ~]# echo "this is a cat" | sed -n /cat/p this is a cat [rootnode1 ~]# echo "this is a cat" | gawk /cat/{print $0} this …