我在虚拟环境中使用Apache运行Django。 一切正常,但10个请求中有1个会导致HTTP 500错误
当我看到我看到的日志时,
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] mod_wsgi (pid=32122): Exception occurred processing WSGI script '/opt/juniper/config/wsgi.py'.
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] Traceback (most recent call last):
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] File "/opt/pythonenv/juniper/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] self.load_middleware()
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] File "/opt/pythonenv/juniper/lib/python2.7/site-packages/django/core/handlers/base.py", line 46, in load_middleware
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] File "/opt/pythonenv/juniper/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] self._setup(name)
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] File "/opt/pythonenv/juniper/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] self._wrapped = Settings(settings_module)
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] File "/opt/pythonenv/juniper/lib/python2.7/site-packages/django/conf/__init__.py", line 128, in __init__
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] mod = importlib.import_module(self.SETTINGS_MODULE)
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] File "/opt/pythonenv/juniper/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] __import__(name)
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] File "/opt/pythonenv/juniper/lib/python2.7/site-packages/configurations/importer.py", line 135, in load_module
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] mod.__package__))
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] File "/opt/pythonenv/juniper/lib/python2.7/site-packages/configurations/importer.py", line 131, in load_module
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] cls = getattr(mod, self.name)
[Thu Jul 17 10:52:26 2014] [error] [client 10.9.16.182] AttributeError: Couldn't find configuration 'Local' in module 'boxy': 'module' object has no attribute 'Local'
返回500的应用程序是杜松。但是我发现错误是在boxy(?)
中寻找本地配置继承我的 wsgi.py
import os,sys,site
site.addsitedir("/opt/pythonenv/juniper/lib/python2.7/site-packages")
sys.path.append('/opt/juniper/')
#sys.path.append('/opt/')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
os.environ.setdefault('DJANGO_CONFIGURATION', 'Local')
#import django.core.handlers.wsgi
#application = django.core.handlers.wsgi.WSGIHandler()
from configurations.wsgi import get_wsgi_application
application = get_wsgi_application()
MIDDLEWARE设置为:
class Local(Common):
MIDDLEWARE_CLASSES = Common.MIDDLEWARE_CLASSES + ('debug_toolbar.middleware.DebugToolbarMiddleware',)
class Common(Configuration):
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
我错过了一些简单的事情吗?
答案 0 :(得分:0)
我设法通过
解决了这个问题谢谢,