Django 1.4本地500错误页面

时间:2012-08-28 17:19:30

标签: django

由于在DEBUG = True且TEMPLATE_DEBUG = True的情况下移动到Django 1.4,当我在本地遇到错误时,我不再看到带有回溯的典型黄色错误屏幕。相反,我得到一个普通的白色屏幕,上面写着“发生错误。请检查您的日志......”。这是新行为,还是我通过组合1.3和1.4文件和设置搞砸了。

这是example of my local settings.

1 个答案:

答案 0 :(得分:1)

错误处理程序 位于django.core.handler.base中尝试调试handle_uncaught_exception函数。

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.
    """
    from django.conf import settings

    if settings.DEBUG_PROPAGATE_EXCEPTIONS:
        raise

    logger.error('Internal Server Error: %s', request.path,
        exc_info=exc_info,
        extra={
            'status_code': 500,
            'request': request
        }
    )

    if settings.DEBUG:
        from django.views import 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:
        raise exc_info[1], None, exc_info[2]
    # Return an HttpResponse that displays a friendly error message.
    callback, param_dict = resolver.resolve500()
    return callback(request, **param_dict)

检查您在debug.technical_500_response

中传递的调试器