小牛的Django和mysql问题 [英] Django and mysql problems on Mavericks
问题描述
我跑了$ code> python manage.py runserver 与mysql.connector.django
作为引擎已经看到一个例子这里,我收到这个错误:
django.core.exceptions.ImproperlyConfigured:'mysql.connector.django'不是可用的数据库后端。
尝试使用'django.db.backends.XXX',其中XXX是以下之一:
u'mysql',u'oracle',u'postgresql_psycopg2',u'sqlite3'
错误是:没有名为mysql.connector.django.base的模块
所以我切换回默认使用django.db.backends.mysql
作为我的引擎,我得到这个错误:
django.core.exceptions.ImproperlyConfigured:加载MySQLdb模块时出错:没有名为MySQLdb的模块
我不知道如何进行。我不能安装MySQLdb,因为我在python3下运行我的django安装,并且它不受支持,但我绝对缺少这个连接器的东西。
对于python 2.7,3.3+,有一个名为 mysqlclient 的驱动程序,可用于django 1.8
pip install mysqlclient
在您的设置中
DATABASES = {
'default':{
'NAME' :'',
'ENGINE':'django.db.backends.mysql',
'USER':'',
'PASSWORD':'',
}
}
这是关于mysql驱动程序的官方django文档:
https://docs.djangoproject.com /en/1.8/ref/databases/#mysql-db-api-drivers
I'm running Mac OSX 10.9 Mavericks. I'm trying to run django under python 3. Because I'm running Python 3 I have to get the official connector from the mysql devs here gave it a quick test in the shell and it works.
I ran python manage.py runserver
with "mysql.connector.django"
as the engine having seen an example here and I got this error:
django.core.exceptions.ImproperlyConfigured: 'mysql.connector.django' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: No module named mysql.connector.django.base
So I switch back to the default using "django.db.backends.mysql"
as my engine and I get this error:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I have no idea how to proceed. I can't install MySQLdb because I'm running my django install under python3 and it's unsupported, but I'm definitely missing something with this connector.
For python 2.7, 3.3+ there is a driver called mysqlclient that works with django 1.8
pip install mysqlclient
And in your settings
DATABASES = {
'default': {
'NAME': '',
'ENGINE': 'django.db.backends.mysql',
'USER': '',
'PASSWORD': '',
}
}
Here's the official django documentation about the mysql drivers:
https://docs.djangoproject.com/en/1.8/ref/databases/#mysql-db-api-drivers
这篇关于小牛的Django和mysql问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!