Reputation: 841
I'm triying to define a custom 500 error for my django app by just placing my 500.html file in the templates folder.
{% extends "base.html" %}
{% load static %}
{% block body %}
<div class="container">
<div class="row">
UPS, algo fue mal.
</div>
</div>
{% endblock %}
Whitout the first line( extending the skeleton of the web) it works, but with it i got this meesage:
A server error occurred. Please contact the administrator.
I'm dooing the exact same thing for the 404 errors, and I works perfectly. I'm completly lost here.
Upvotes: 1
Views: 268
Reputation: 29967
Your base.html
probably expects some context which is not passed in by the default 500 view. From the 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.
If that is the case you can either:
base.html
works properly with an empty context orI think option 1 is the preferred option because it ensures that the 500 page can always be displayed. The downside is that any changes in your base.html
, you might have to apply to your 500 template as well.
Option 3 is the least preferred because it carries the highest risk of the 500 page not rendering,e.g. if the 500 is caused because the DB is unavailable and your custom 500 view tries to use the DB.
Upvotes: 2