When Django encounters an error and needs to serve a 404 (Page Not Found) or 500 (Server Error) response, it looks for the files called 404.html
and 500.html
(respectively) in the root of your templates directory. If you have more than one directory in your TEMPLATE_DIRS
setting, it will search each one in order until it finds the required file.
If it can't find the 404.html
file, Django will serve a TemplateDoesNotExist
error. If it can't find the 500.html
file, you'll get the most generic-looking error page your web server provides.