我的简单manage.py runserver
Django应用程序在调试模式(Bad Request (400)
查看(无论是在我的应用程序中还是在 Django 管理员中。
在哪里可以找到有关此的调试信息?什么都没有出现/var/log/apache2/error.log
,即使是LogLevel=info
. 我检查了版本,记录了请求环境(参见ModWSGI 调试提示),没有发现重大差异。
我剩下的一个想法是,我正在使用基于 Python 2.7.1 构建的 Ubuntu 12.04 (libapache2-mod-wsgi 3.3-4build1) 的 mod_wsgi;我有 Python 2.7.3。而 Django 是 1.6,比 Ubuntu Precise 版本更新。我犹豫是否开始从源代码构建软件包,因为清理起来非常困难,而且这些看起来像是次要的版本更改......
谢谢您的帮助。
(供参考,这里是 Apache 配置和 WSGI 应用程序)
Apache 配置(000-默认)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
WSGIScriptAlias /rz /usr/local/share/rz/rz.wsgi
...
rz.WSGI 应用程序
import os
import sys
import django.core.handlers.wsgi
import pprint
path = '/usr/local/share/rz'
if path not in sys.path:
sys.path.insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'rz.settings'
class LoggingMiddleware:
def __init__(self, application):
self.__application = application
def __call__(self, environ, start_response):
errors = environ['wsgi.errors']
pprint.pprint(('REQUEST', environ), stream=errors)
def _start_response(status, headers, *args):
pprint.pprint(('RESPONSE', status, headers), stream=errors)
return start_response(status, headers, *args)
return self.__application(environ, _start_response)
application = LoggingMiddleware(django.core.handlers.wsgi.WSGIHandler())