如何让django 打印500具体错误信息

C:\Python27\Lib\site-packages\django\core\handlers\base.py   在这个base.py文件上加一段代码 def handle_uncaught_exception(self, request, resolver, exc_info): """ Processing for any otherwise uncaught exceptions (those that will generate HTTP 500 responses). Can be overridden by subclasses who want customised 500 handling.   Be *very* careful when overriding this because the error could be caused by anything, so assuming something like the database is always available would be an error. """ if settings.DEBUG_PROPAGATE_EXCEPTIONS: raise   logger.error('Internal Server Error: %s', request.path, exc_info=exc_info, extra={ 'status_code': 500, 'request': request } )   #加上这段代码后,便可以打印出来了 #===========Code start =======by chang print "------HTTP 500 Error Msg" print exc_info import traceback print traceback.format_exc() print "------------------------" #============Code end================   if settings.DEBUG: return debug.technical_500_response(request, *exc_info)   # If Http500 handler is not installed, re-raise last exception if resolver.urlconf_module is None: six.reraise(*exc_info) # Return an HttpResponse that displays a friendly error message. callback, param_dict = resolver.resolve_error_handler(500) return callback(request, **param_dict)
上一篇:sys模块


下一篇:python 杂记20191102