29.2.1 Creating Error Pages
As we were developing, anytime we asked for a page that didn’t exist or that caused the server to error horribly, Django would catch the error and then tell us what was going on internally. Leaking this information to a stranger on the internet is a terrible idea. In the next section, we disable this behavior by changing the DEBUG setting to False. However, when we do, Django will begin to look for templates that we have not created yet.
These templates will be loaded and rendered with a RequestContext whenever a problem occurs. When a URL path that doesn’t match a URL pattern is received by Django, Django will load and render the 404.html in the root of our template namespace. We therefore create the templates/404.html ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access