Django 500.html模板未用于Amazon Elastic Beanstalk上的内部服务器错误

Django 500.html模板未用于Amazon Elastic Beanstalk上的内部服务器错误,django,amazon-web-services,amazon-elastic-beanstalk,Django,Amazon Web Services,Amazon Elastic Beanstalk,我不明白为什么django不使用我的500.html模板来处理服务器错误。 我在Elastic Beanstalk上部署了我的应用程序,虽然所有404请求都由404.html模板处理,但500个错误显示标准apache错误: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please cont

我不明白为什么django不使用我的500.html模板来处理服务器错误。 我在Elastic Beanstalk上部署了我的应用程序,虽然所有404请求都由404.html模板处理,但500个错误显示标准apache错误:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/2.2.25 (Amazon) Server at myapp.elasticbeanstalk.com Port 80

可能是什么?(我把两个模板放在同一个地方)

我曾经遇到过类似的问题,因为我在我的500.html模板中使用了上下文变量。但默认情况下,Django不向500错误页面提供任何上下文。因此,这会导致一个“双重”错误,即呈现错误页面本身会创建一个错误

从Django文档中:

默认的500视图不向500.html模板传递任何变量,并且 使用空上下文进行渲染,以减少发生其他错误的可能性 错误

因此,如果在500错误页面中使用任何上下文变量,可能就是这样。但不确定这对你的情况是否有帮助


如果这就是问题所在,那么解决方案就是编写一个自定义的错误处理视图,该视图使用最小的上下文来呈现静态文件等(如上面文档中所述)

是否所有500个错误都显示了这些错误,即使是您故意创建的错误?或者这可能是一个特定的错误?嗯。。。好问题。。。实际上,该错误是由未处理的DoesNotExist异常引起的。。。因此,在我看来,一个简单的错误案例必须由框架使用500.html模板来处理。请检查是否设置了[DEBUG_PROPAGATE_EXCEPTIONS]()。另外,请看一下日志,apache和django的你都将成为我最好的书呆子朋友D