我想使用这个集:Ubuntu 12.04 + Python 3.3 + Django 1.6 + MySQL 5.5;
对于我使用的支持MySQL" Connector / Python Django Backend" (link)。
我的设置:
DATABASES = {
'default': {
'NAME': 'test',
'ENGINE': 'mysql.connector.django',
'USER': 'root',
'PASSWORD': '****',
'OPTIONS': {
'autocommit': True,
},
}
}
这是工作。
但是我想使用" South"。我成功安装了" South"。
pip install south==0.8.4
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
)
这里发生了什么
python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 75, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
File "<frozen importlib._bootstrap>", line 1512, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1022, in load_module
File "<frozen importlib._bootstrap>", line 1003, in load_module
File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 868, in _load_module
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/south/management/commands/__init__.py", line 13, in <module>
from south.management.commands.syncdb import Command as SyncCommand
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/south/management/commands/syncdb.py", line 19, in <module>
from south.db import dbs
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/south/db/__init__.py", line 83, in <module>
db = dbs[DEFAULT_DB_ALIAS]
KeyError: 'default'
怎么做?
答案 0 :(得分:3)
支持MySQL需要使用MySQL-for-Python-3(link)
安装:
$ tar xfz MySQL-python-1.2.1.tar.gz
$ cd MySQL-python-1.2.1
$ python setup.py build
$ sudo python setup.py install
接下来是Django官方手册。