Django创建mysql外键

1.将mysql默认引擎设置为InnoDB

2.修改settings.py

 1 DATABASES = {
 2     'default': {
 3         'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
 4         'NAME': 'online_auction',                      # Or path to database file if using sqlite3.
 5         # The following settings are not used with sqlite3:
 6         'OPTIONS':{
 7             'init_command':'SET storage_engine=INNODB',
 8         },
 9         'USER': 'root',
10         'PASSWORD': '',
11         'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
12         'PORT': '',                      # Set to empty string for default.
13     }
14 }

 

posted @ 2013-07-12 20:35  支點  阅读(500)  评论(0编辑  收藏  举报