When something goes wrong on your site such as a missing page, a server error, or a permission problem, you will want to display error page that keep your site's styling and are on brand for your webapp. You can easily create custom templates for common HTTP error codes in Django.
By default, Django automatically looks in your root level templates directory for the following files:
- templates/404.html
- templates/500.html
- templates/403.html
- templates/400.html
These don't require views or URLs and Django will serve them automatically when those errors occur. Therefore, you should create your HTML files here and name then using the names given above.
Testing them is not possible in development so your site will need to be deployed in order to show the error pages you have created when that error is caused.
Note that due to the location of the error pages, there are no associated views.py files so if you need to load any information that you would normally do through a view, you will need to pass it through a context processor outlined here in the core app section.