首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Django配置: settings.DATABASES配置不当

Django配置: settings.DATABASES配置不当
EN

Stack Overflow用户
提问于 2014-02-27 05:55:24
回答 2查看 592关注 0票数 0

我启动了Django项目,但是数据库设置出现了错误。网页运作良好:

代码语言:javascript
复制
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!

但是我知道这个错误是控制台:

代码语言:javascript
复制
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 
...

数据库设置:

代码语言:javascript
复制
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': ''
#    }
#}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-02-27 06:03:55

Django 1.6期望数据库是一本字典。您将其注释掉,并在其中放置一些较旧的设置格式。您应该将其更改为:

代码语言:javascript
复制
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '',
        'HOST': 'localhost',
        'PORT': '',
        'USER': '',
        'PASSWORD': ''
    }
}

在这里可以看到更多关于这个的信息:https://docs.djangoproject.com/en/1.6/ref/databases/

票数 3
EN

Stack Overflow用户

发布于 2014-02-27 06:06:49

您正在使用的设置变量DATABASES_*,这已经是遭到反对的Django 1.2,5年前现在!

您需要使用字典,因为默认设置可能已为您预先填充:

代码语言:javascript
复制
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '',
        'HOST': 'localhost',
        'PORT': '',
        'USER': '<user>',
        'PASSWORD': ''
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22060182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档