I am implementing custom 404 and 500 templates, but although the 404.html template seems to return request.user.is_authenticated fine, the 500.html template does not return anything. I also checked for request.user and it is just empty on page 500.
This is very strange because when I run the 500 error, I get the expected error message error message, and it clearly has a USER correctly defined in the request breakdown. Here is the code I use in views.py:
def handler404(request): response = render_to_response('404.html', {}, context_instance=RequestContext(request)) response.status_code = 404 return response def handler500(request): response = render_to_response('500.html', {}, context_instance=RequestContext(request)) response.status_code = 500 return response
I am wondering if something in the background (maybe in RequestContext) is processing 500 other than 404? I have to mention that I also use django-guardian, although I do not think that would affect anything in this case. Any ideas?
Edit: This comment states that "template 500 will not display request.user because it reports a server 500 error, so the server cannot serve anything." Does anyone know about this? It seems like there should be one, because, as I said, the log I get in the error message explicitly has a request object with a username.
Edit 2: Now I wonder if this is related to django-allauth - I use it too.
Gravity Grave Sep 25 '14 at 16:08 2014-09-25 16:08
source share