3👍
✅
FOUND THE SOLUTION
I had a setting called DEBUG_PROPAGATE_EXCEPTIONS
set to True
. This seemed to disable my custom handler. It works perfectly now.
3👍
-2👍
Quoting Django documentations
If you implement a custom view, be sure it accepts a
request
argument and returns anHttpResponseServerError
.
You have to return anHttpResponseServerError
in yourhandler500
.
A very simple way to implement all this is just include in your views
def handler500(request, exception, template_name="my_template.html"):
response = render_to_response("my_template.html")
response.status_code = 500
return response
This way you don’t need to change anything in your URLConfs. This approach does require that your template is at the top of the root template folder. Maybe name it “500.hml” and it would jump up to the top.
- [Django]-Bitnami Django creating multiple projects
- [Django]-Django {% blocktrans %}: How to handle pluralization inside a for loop?
- [Django]-Django hide all form errors
- [Django]-Django+Heroku: compilemessages works but not MY translation file.
- [Django]-Django 2.1 NOT NULL Constraint Failed When Creating Super User
Source:stackexchange.com