在尝试设置Django时出现错误配置(“settings.DATABASES配置不正确”)错误 [英] ImproperlyConfigured("settings.DATABASES is improperly configured. ") error when trying to set up Django

查看:4203
本文介绍了在尝试设置Django时出现错误配置(“settings.DATABASES配置不正确”)错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图按照此处的说明在Heroku上设置Django实例。



尽可能安装Celery,直至以下步骤:

  $ python manage.py syncdb 

当我收到以下错误:


引发错误配置(settings.DATABASES不正确地配置
。django.core.exceptions.ImproperlyConfigured:
settings.DATABASES配置不正确。请提供ENGINE
值。查看设置文档以获取更多详细信息。


我相信我的 settings.py 文件放在正确的位置(project-name / project-name),我正在运行django 1.4.3,但是当我尝试运行 manage.py diffsettings 时,我得到以下输出:


< BROKER_BACKEND ='dj ango'### DATABASES = {'default':{'ENGINE':
'django.db.backends.dummy','TEST_MIRROR':None,'NAME':'',
'TEST_CHARSET ':None,'TIME_ZONE':'UTC','TEST_COLLATION':None,
'PORT':'','HOST':'','USER':'','TEST_NAME':None,'' PASSWORD':'',
'OPTIONS':{}}}


绝对不知道 django.db.backends.dummy 条目来自我的 settings.py 具有'ENGINE':'django .db.backends.postgresql_psycopg2',我认为这是正确的条目,即使Heroku指令不告诉你在任何时候更新它。



有什么想法我需要在这里编辑?

解决方案

我遇到了同样的问题。在Heroku文档中 https://devcenter.heroku.com/articles/django#prerequisites,它表示将以下内容添加到 settings.py

  DATABASES ['default'] = dj_database_url.config()

您可以传入以下参数:

  DATABASES ['default'] = dj_database_url.config(default ='postgres:// user:pass @ localhost / dbname') 

这样可以让您在本地和Heroku上进行开发。实际上解决了我遇到的问题的部分是DATABASE_URL的Heroku配置环境变量没有实际设置。为了设置这个,我跑了

  $ heroku config 

我看到分配给单独配置变量的数据库URL。所以我创建了一个新的变量:

$ $ $ $ $ $ $ $ $ $ $ code>

解决了我的问题。我希望它能帮助其他有类似问题的人。

Attempting to follow the instructions here to set up a Django instance on Heroku.

Got as far as the installation of Celery, up to the following step:

$ python manage.py syncdb

when I get the following error:

raise ImproperlyConfigured("settings.DATABASES is improperly configured. "django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

I believe that I have my settings.py file in the right place (project-name/project-name), and I'm running django 1.4.3, but when I try to run manage.py diffsettings, I get the following output:

BROKER_BACKEND = 'django' ### DATABASES = {'default': {'ENGINE': 'django.db.backends.dummy', 'TEST_MIRROR': None, 'NAME': '', 'TEST_CHARSET': None, 'TIME_ZONE': 'UTC', 'TEST_COLLATION': None, 'PORT': '', 'HOST': '', 'USER': '', 'TEST_NAME': None, 'PASSWORD': '', 'OPTIONS': {}}}

Absolutely no idea where the django.db.backends.dummy entry comes from, my settings.py has 'ENGINE': 'django.db.backends.postgresql_psycopg2', which I assume is the correct entry even though the Heroku instructions don't tell you to update it at any point.

Any thoughts what I need to edit here?

解决方案

I ran into the same issue. In the Heroku docs at https://devcenter.heroku.com/articles/django#prerequisites, it says to add the following to settings.py:

DATABASES['default'] =  dj_database_url.config()

You can pass in a parameter of:

DATABASES['default'] =  dj_database_url.config(default='postgres://user:pass@localhost/dbname')

And that will allow you to develop locally and on Heroku. The part that actually SOLVES the problem I had though was that the Heroku config environment variable of DATABASE_URL was not actually set. To set this, I ran

$ heroku config

I saw the Database URL assigned to a separate config variable. So I created a new variable:

$ heroko config:add DATABASE_URL={#the database url}

That solved my problem. I hope it helps anyone else with similar issues.

这篇关于在尝试设置Django时出现错误配置(“settings.DATABASES配置不正确”)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆