我在 virtualenv 中使用 Django 1.5.1,在 OS X 10.8.4 上使用 Python 2.7。我在 Django 设置中从 更改DEBUG = True
为DEBUG = False
,但出现错误:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Users/kilroy/.virtualenvs/project_name/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 255, in __call__
response = self.get_response(request)
File "/Users/kilroy/.virtualenvs/project_name/lib/python2.7/site-packages/django/core/handlers/base.py", line 178, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/kilroy/.virtualenvs/project_name/lib/python2.7/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception
return callback(request, **param_dict)
File "/Users/kilroy/Sites/PYTHON/project_name/apps/common/views.py", line 436, in handler_500
messages.error(request, '500 - Internal server error.')
File "/Users/kilroy/.virtualenvs/project_name/lib/python2.7/site-packages/django/contrib/messages/api.py", line 102, in error
fail_silently=fail_silently)
File "/Users/kilroy/.virtualenvs/project_name/lib/python2.7/site-packages/django/contrib/messages/api.py", line 22, in add_message
raise MessageFailure('You cannot add messages without installing '
MessageFailure: You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware
我使用不同的设置文件进行开发和生产,在我的开发机器上,我在/Users/kilroy/.virtualenvs/project_name/bin/postactivate
文件中设置环境变量,如下所示:
export DJANGO_SETTINGS_MODULE=project_name.settings.local
我的base.py
文件看起来像这样https://dpaste.de/avXmL/,我的local.py
设置像这样https://dpaste.de/Z0PXv/。
当我想禁用调试时为什么会发生这种情况,我如何追踪为什么会首先出现这个问题?