运行django 1.3。如果我在视图中有一个未处理的异常,例如
def test(request):
raise Exception('error')GETing页面(这里通过wget):
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'
[ <=> ] 218 --.-K/s in 0s
2011-08-04 17:47:43 (14.9 MB/s) - `index.html' saved [218]Index.html的内容:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>Unhandled Exception</title>
</head><body>
<h1>Unhandled Exception</h1>
<p>An unhandled exception was thrown by the application.</p>
</body></html>现在来看问题:为什么响应状态码是200?应该是500。
编辑:使用命令在lighttpd上运行
manage.py runfcgi --settings=$SETTINGS socket=$SOCKET pidfile=$PIDFILE method=prefork minspare=1 maxspare=1 maxchildren=10 maxrequests=100"settings.py中的DEBUG=FALSE。如果我更改为DEBUG=TRUE,则响应状态代码为正确的500。
发布于 2011-08-05 01:30:11
对于DEBUG = False,它将尝试运行500.html模板。你创建那个文件了吗?
https://stackoverflow.com/questions/6944570
复制相似问题