How to customize error pages in Python Django?

Python Django Handling Custom Error Page

Every web site needs to handle errors like HTTP 404 “page not found” or 500 “internal server errors”. For Django based web server when these errors occur, the web server will show active server’s settings.

I added basic steps about handling Custom Error Page. For production service it should be more critical then development platform disables DEBUG mode and also customize error pages.

By default, Python Django manages these error codes with handlerxxx under file.

Step 1: Edit file


— Change debug level

— Define template directory for HTML

— Add project to installed apps

Step 2: Add handler method to

There are 4 already defined handler methods in django.urls functions. To change default configuration;

For my project “myappname” is “certman”.


Step 3: Edit file

You need to define an error function to the Add these lines to manage handlerxxx.



Step 4: Define HTML file (404.html, 500.html, etc)

Add customized HTML files under the templates directory.

Step 5: Restart python Django project

Follow me


I'm a System Engineer with extensive experience and administration skills and works for Interbank Card Center Of Turkey.I provide hardware and software support for the following Unix/Linux and Windows platforms.(Oracle Solaris,HP-UX, Linux, IBM-AIX, Windows Servers)
Follow me
facebooktwittergoogle_pluslinkedinby feather