In one of my views, I have the code:
raise Http404
When DEBUG=False Django displays a 500.html template instead of the correct 404.html ! I do not understand why!
EDIT: When DEBUG=True , I get the standard one (by Django)
Page not Found (404) You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
What else in the runserver console runserver I see clearly 404 code. Instead , when setting DEBUG=False in the console, I get 500 !! This is so strange.
EDIT 2: If I put a print statement just before the Http404 promotion, I see a message when DEBUG=True , but not when it is False !
EDIT 3: I can confirm that when DEBUG=False the raise Http404 never reached. How is this possible?
Update
Actually with DEBUG=False on every URL I get 500. Although with DEBUG=True this does not happen. How is this possible? It should work the same. I'm starting to think that this is a Django bug.
rubik source share