PythonTip >> 博文 >> Django

在django中定制500错误(handler500 )

zihua 2014-01-16 18:01:55 点击: 821 | 收藏


py:
def custom_500(request):
    import traceback
    template_name = '500.html'
    t = loader.get_template(template_name)
    error = str(traceback.format_exc())
    return http.HttpResponseServerError(t.render(Context({'error': error})))

然后在url.py中加上
handler500 = 'aaa.base.processor.custom_500'
http://www.zuoann.com
原文链接:http://my.oschina.net/zuoan001/blog/80467

作者:zihua | 分类: Django | 标签: django | 阅读: 821 | 发布于: 2014-01-16 18时 |