Django 1.11 404 Page while Debug=True

Viewed 6666

Without making things difficult, I just want to show a special 404 render with staticfiles.

If you set DEBUG = False you can use in urls.py

handler404 = 'app.views.handler404'

But it is without staticfiles. I don't want to install a web server for a simple app.

With DEBUG = True in urls

url(r'^404/$', views.handler400)

is not overriding the default Page not found (404) page.

What is the easy way to achieve a render e.g. when you type localhost/asdfhjfsda with staticfiles when DEBUG=True?

Thanks in advance...

3 Answers

Easiest way to do this post Django 1.9 is in your urls.py:

from django.views.defaults import page_not_found

url(r'^404/$', page_not_found, {'exception': Exception()})

It wants an exception, give it an exception :)

Related