我启动了一个Django项目,但是我收到了数据库设置错误。主页工作正常:
It worked!
Congratulations on your first Django-powered page.
Of course, you haven't actually done any work yet. Next, start your first app by
running python manage.py startapp [appname].
You're seeing this message because you have DEBUG = True in your Django settings file
and you haven't configured any URLs. Get to work!
但我得到的错误是控制台:
settings.DATABASES is improperly configured. Please supply the ENGINE
value. Check settings documentation for more details.
Request Method: GET Request URL: http://fireidea.net/ Django
Version: 1.6.2 Exception Type: ImproperlyConfigured Exception Value:
settings.DATABASES is improperly configured. Please supply the ENGINE
value. Check settings documentation for more details.
Exception Location:
/home2/minhhien/webapps/django/django/db/backends/dummy/base.py in
complain, line 15 Python Executable: /usr/bin/python Python Version:
2.7.5
...
数据库设置:
MANAGERS = ADMINS
DATABASE_ENGINE = 'mysql'
DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = 'localhost'
DATABASE_PORT = ''
#DATABASES = {
# 'default': {
# 'ENGINE': '',
# 'NAME': '',
# 'HOST': 'localhost',
# 'PORT': '',
# 'USER': '',
# 'PASSWORD': ''
# }
#}
答案 0 :(得分:3)
Django 1.6期望DATABASES是一本字典。 你评论了它,并在那里放了一些旧的设置格式。 你应该把它改回:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '',
'HOST': 'localhost',
'PORT': '',
'USER': '',
'PASSWORD': ''
}
}
点击此处了解详情:https://docs.djangoproject.com/en/1.6/ref/databases/
答案 1 :(得分:1)
您正在使用5年前已经deprecated in Django 1.2的设置变量DATABASES_*
!
您需要使用字典,因为默认设置可能已为您预先填写:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '',
'HOST': 'localhost',
'PORT': '',
'USER': '<user>',
'PASSWORD': ''
}
}