日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發(fā)布時間:2023/12/9 数据库 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 django 创建mysql失败_创建表时出现Django MySQL错误 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我正在用MySQL數(shù)據(jù)庫構建一個django應用程序。當我第一次運行“python manage.py migrate”時,一些表創(chuàng)建得很好,然后出現(xiàn)一些錯誤。出現(xiàn)的錯誤是: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')

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結

以上是生活随笔為你收集整理的django 创建mysql失败_创建表时出现Django MySQL错误的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。