Johan Vergeer Johan Vergeer - 7 months ago 124
Python Question

Django 1.10 404.html template not found

As far as I have seen in the Django documentation, to show a custom 404 page all you have to do is put a 404.html in the root templates directory.

So my project structure is:

|_ config
| |_
| |_
|_ templates
|_ base.html
|_ index.html
|_ 404.html

In I have the following settings for the templates:

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ["templates", ]
'APP_DIRS': True,
'context_processors': [

for the
parameter I also used
os.path.join(BASE_DIR, "templates")
. This had the exact same outcome.

I also used

os.path.join(BASE_DIR, "templates"),

This lead to a deprecation warning.

In I also did not really do anything special:

from django.conf.urls import url, include
from django.contrib import admin
from django.views.generic import TemplateView

urlpatterns = [
url(r'^$', TemplateView.as_view(template_name="index.html"), name="index"),


Template inheritance is working perfectly in other apps, so the templates directory is found.

In settings:

When I enter a wrong url I get the Django default 'NOT FOUND' page.

What am I missing here?


you need override 'handler404' variable, add this to

from django.conf.urls import handler404

handler404 = 'your_app.views.404'