2012-08-28 55 views
0

由于使用DEBUG = True和TEMPLATE_DEBUG = True移动到Django 1.4,当我在本地遇到错误时,我不再看到带回溯的典型黄色错误屏幕。相反,我会看到一个普通的白色屏幕,上面写着“出现错误,请检查日志......”。这是新的行为还是我通过组合1.3和1.4文件和设置搞砸了一些东西。Django 1.4本地500错误页面

下面是一个example of my local settings.

+0

你在其他地方一定有问题,因为tracebac k细节页面仍然是django的一部分1.4调试模式 – jdi

+0

我该如何运行它?我在localhost服务器中看到了正确的错误信息。我是否通过使用STATIC_URL而保持MEDIA_URLS导致冲突?我已通过链接指向示例设置更新了帖子。 – Tom

+0

你正在使用'python manage.py runserver'? 'runserver'管理命令不会保留日志,所以你的错误似乎表明你正在运行一个真正的web服务器。 –

回答

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 

检查,如果你路过这里 回报debug.technical_500_response(请求,* 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

通过调试器
+0

啊,你让我去修理。有关[改变我的项目的框架代码(https://bitbucket.org/tclancy/deployment/changeset/06d72a3c12d8c1b2a1e9fa09e27e19be151a2f98#chg-DjangoDefaults/project/local_settings.py)工作时,由于某种原因,我加入DEBUG_PROPAGATE_EXCEPTIONS =真我的设置,但我设法不粘贴时,我被改写的我的例子文件一起上引擎收录。小结总结:我是个白痴。谢谢。 – Tom