Nikolay Blokhin Facebook Nikolay Blokhin Instagram Nikolay Blokhin Linkedin Nikolay Blokhin Twitter

Hi, I'm Nikolay Blokhin I build the cool things with Python and Swift

Custom 404 page for Django

Creation of your own, custom page for 404 error (page not found), is very simple in Django. You must add just few lines.

In urls.py:

from django.conf.urls import handler404 ... handler404 = 'your_project.your_app.views.page_not_found'

In views.py:

@render_to('404.html')
def page_not_found(request):
    ...
    return {...}
(I hope you already have your custom decorator "render_to")

And last step: create the template "404.html" with any content. It's what customer see when page was not found (error 404):