MCPcopy
hub / github.com/django/django / server_error

Function server_error

django/views/defaults.py:83–99  ·  view source on GitHub ↗

500 error handler. Templates: :template:`500.html` Context: None

(request, template_name=ERROR_500_TEMPLATE_NAME)

Source from the content-addressed store, hash-verified

81
82@requires_csrf_token
83def 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

Callers 2

test_error_pagesMethod · 0.90

Calls 3

get_templateMethod · 0.45
renderMethod · 0.45

Tested by 2

test_error_pagesMethod · 0.72