500 error handler. Templates: :template:`500.html` Context: None
(request, template_name=ERROR_500_TEMPLATE_NAME)
| 81 | |
| 82 | @requires_csrf_token |
| 83 | def server_error(request, template_name=ERROR_500_TEMPLATE_NAME): |
| 84 | """ |
| 85 | 500 error handler. |
| 86 | |
| 87 | Templates: :template:`500.html` |
| 88 | Context: None |
| 89 | """ |
| 90 | try: |
| 91 | template = loader.get_template(template_name) |
| 92 | except TemplateDoesNotExist: |
| 93 | if template_name != ERROR_500_TEMPLATE_NAME: |
| 94 | # Reraise if it's a missing custom template. |
| 95 | raise |
| 96 | return HttpResponseServerError( |
| 97 | ERROR_PAGE_TEMPLATE % {"title": "Server Error (500)", "details": ""}, |
| 98 | ) |
| 99 | return HttpResponseServerError(template.render()) |
| 100 | |
| 101 | |
| 102 | @requires_csrf_token |