开发者

Make Django Create Foreign Keys for MySQL Backend

开发者 https://www.devze.com 2023-01-30 14:16 出处:网络
How do you force Django to create real foreign key constraints when using a MySQL backend? If I\'m reading this old bug report correctly, Django shou开发者_JS百科ld be creating real foreign keys, but

How do you force Django to create real foreign key constraints when using a MySQL backend? If I'm reading this old bug report correctly, Django shou开发者_JS百科ld be creating real foreign keys, but my default Django 1.2.3 setup using MySQL only generates indexes for models.ForeignKey().


Change your database engine to InnoDB. MyISAM doesn't support foreign keys.


I'm running on Django 1.2.1 with MySQL_python-1.2.3c and can verify that it is indeed creating proper foreign key entries on MySQL.

I suggest that you check if you are using MySQL_python-1.2.3c or better

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号