Django 500.html template not used for internal server error on Amazon Elastic Beanstalk
amazon-elastic-beanstalk, amazon-web-services, django
Solution
I had a similar problem once because I was using context variables in my 500.html template. But by default Django does not provide any context to the 500 error page. So that leads to a "double" error, where the rendering the error page itself creates an error.
From the Django documentation:
The default 500 view passes no variables to the 500.html template and is rendered with an empty Context to lessen the chance of additional errors.
https://docs.djangoproject.com/en/dev/topics/http/views/#the-500-server-error-view
So if you use any context variables in your 500 error page, that's probably what happened. Not sure if this helps in your case though...
If that was the problem, the solution would be to write a custom error handling view with a minimal context to render static files etc (as described in the documentation above).
Problem
I don't understand why django is not using my 500.html template for server errors. I deployed my app on Elastic Beanstalk, and while all 404 requests are handled by the 404.html template, 500 errors show the standard apache error: ``` 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 ``` What could be? (I've got both the templates in the same place)