0

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

这是我的本地设置的示例。

4

1 回答 1

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 中传递的调试器

于 2012-09-06T14:16:44.370 回答