Tutorial: views.py, detail, Http404

Hello,
in part 3 of the tutorial ( Writing your first Django app, part 3 | Django documentation | Django ), there is a demonstration of using Http404 (“Raising a 404 error”).
My question is this.

If I have DEBUG=True in settings.py, I have a nice debug error page which in particular displays the phrase:
”Question does not exist” ––
according to the exception in the function detail(…) in views.py.

But if I have DEBUG=False (which I need to do in real life), I see a dumb 404 page without anything useful for a user.

Is this by design?
I was expecting the same ”Question does not exist” as it is raised in this function:
raise Http404(“Question does not exist”)
Otherwise, it is kind of the same as
raise Http404(“Whatever”).
???
Thank you.

Welcome @Mabooka !

This is intended and as is by design.

You’re typically using DEBUG=False in a situation where your site is exposed to the general public - including individuals potentially having malicious or hostile intent.

In these situations, you do not want to provide information that can be used to help focus an attack against your site.

If you notice most other public sites, such as github.com, microsoft.com, or just about every other major public site, you’ll see that their 404 pages do not reveal any specific detail about why your URL might be wrong.

Side note: You can customize the 404 page being rendered. See Writing views | Django documentation | Django

1 Like

Thank you, makes sense.