Heroku sais:“请求设置LOGGING_CONFIG”但它已设置?

时间:2017-10-07 21:18:01

标签: python django heroku

我正在尝试在Heroku上设置Django网站。我收到此错误消息:

2017-10-07T21:03:33.416585+00:00 app[web.1]:
django.core.exceptions.ImproperlyConfigured: Requested setting 
LOGGING_CONFIG, but settings are not configured. You must either define 
the environment variable DJANGO_SETTINGS_MODULE or call 
settings.configure() before accessing settings.

但是如果我运行Heroku配置,则设置var。为什么不被认可?

=== dagenssalg Config Vars
DISABLE_COLLECTSTATIC: 0
LOGGING_CONFIG:        off

这里的许多答案都提到了wsgi.py文件,但我看不出有什么问题:

import os
from django.core.wsgi import get_wsgi_application
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
os.environ.setdefault("DJANGO_SETTINGS_MODULE","dagenssalg.settings")
application = get_wsgi_application()

非常感谢任何帮助。最诚挚的问候Kresten

1 个答案:

答案 0 :(得分:1)

你的wsgi文件很乱。您导入get_wsgi_application两次,然后在设置环境变量之前调用它;然后使用WhiteNoise正确包装应用程序实例,然后再次调用get_wsgi_application丢弃此实例。

用这个代替整个事情:

import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise 
os.environ.setdefault("DJANGO_SETTINGS_MODULE","dagenssalg.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)