HttpResponseServerError inherits from HttpResponse and is actually quite simple:
class HttpResponseServerError(HttpResponse): status_code = 500
So take a look at the HttpResponse constructor:
def __init__(self, content='', *args, **kwargs): super(HttpResponse, self).__init__(*args, **kwargs)
As you can see the default content empty.
Now let's see how it is called by Django itself (excerpt from django.views.defaults):
def server_error(request, template_name='500.html'): """ 500 error handler. Templates: :template:`500.html` Context: None """ try: template = loader.get_template(template_name) except TemplateDoesNotExist: return http.HttpResponseServerError('<h1>Server Error (500)</h1>') return http.HttpResponseServerError(template.render(Context({})))
As you can see, when you create a server error, a template called 500.html is used, but when you just return an HttpResponseServerError , the content is empty and the browser returns to it by default.
dmg
source share