Getting “ImproperlyConfigured: The SECRET_KEY sett

2019-09-01 09:21发布

I have been following this (http://appsembler.com/blog/django-deployment-using-openshift/) tutorial to deploy mezzanine 3.0.9 with python 2.7 and mysql 5.1

After deploy when I make the http request I am getting following error logs:

[Sat Mar 22 00:44:31 2014] [error] /var/lib/openshift/532c9876e0b8cdcdeb0001c8/python/virtenv/lib/python2.7/site-packages/Mezzanine-3.0.9-py2.7.egg/mezzanine/utils/conf.py:51: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django 1.5 requires. Will fall back to the domains configured as sites.
[Sat Mar 22 00:44:31 2014] [error]   warn("You haven't defined the ALLOWED_HOSTS settings, which "
[Sat Mar 22 00:44:53 2014] [error] /var/lib/openshift/532c9876e0b8cdcdeb0001c8/python/virtenv/lib/python2.7/site-packages/Mezzanine-3.0.9-py2.7.egg/mezzanine/utils/conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match: America/New_York
[Sat Mar 22 00:44:53 2014] [error]   warn("TIME_ZONE setting is not set, using closest match: %s" % tz)
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129] mod_wsgi (pid=501717): Exception occurred processing WSGI script '/var/lib/openshift/532c9876e0b8cdcdeb0001c8/app-root/runtime/repo/wsgi/application'.
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129] Traceback (most recent call last):
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]   File "/var/lib/openshift/532c9876e0b8cdcdeb0001c8/python/virtenv/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/handlers/wsgi.py", line 187, in __call__
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]     self.load_middleware()
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]   File "/var/lib/openshift/532c9876e0b8cdcdeb0001c8/python/virtenv/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/handlers/base.py", line 46, in load_middleware
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]   File "/var/lib/openshift/532c9876e0b8cdcdeb0001c8/python/virtenv/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/conf/__init__.py", line 54, in __getattr__
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]     self._setup(name)
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]   File "/var/lib/openshift/532c9876e0b8cdcdeb0001c8/python/virtenv/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/conf/__init__.py", line 49, in _setup
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]     self._wrapped = Settings(settings_module)
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]   File "/var/lib/openshift/532c9876e0b8cdcdeb0001c8/python/virtenv/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/conf/__init__.py", line 151, in __init__
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129]     raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
[Sat Mar 22 00:44:53 2014] [error] [client 127.8.79.129] ImproperlyConfigured: The SECRET_KEY setting must not be empty.

Here is my settings.py (http://pastebin.com/uJT6VVmm) & wsgi/application file (http://pastebin.com/21DBpUgp).

Can you please help me with the problem.

Thanks

2条回答
一纸荒年 Trace。
2楼-- · 2019-09-01 09:39

I think you have skipped this part of Django Documentation . If SECRET_KEY is not present in settings.py , by default its empty .

SECRET_KEY is generated when you use startproject command. So make sure you have SECRET_KEY in your settings.py or or local_settings.py file .

查看更多
一纸荒年 Trace。
3楼-- · 2019-09-01 09:42

I've just created a quickstart for setting up mezzanine on openshift, I've also created there a very detailed description how to setup mezzanine from scratch. From what I've experienced setting this up here are my modifications to settings.py:

  • check SECRET_KEY and NEVERCACHE_KEY
  • check databases settings
  • check ALLOWED_HOSTS to include .rhcloud.com
查看更多
登录 后发表回答