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 ...

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.