Djano 404 Page Django.How

Author avatar wrote on 26/05/2022

Create page

Create a page 404.html and add it to the template folder

Test it

In the default file Django sets DEBUG = True and ALLOWED_HOSTS = []. We want to change both. Turning off debug will show us what a live site would show and ALLOWED_HOSTS restricts which HTTP requests Django will respond to so the URL needs to be explicitly added.

# demo_project/
DEBUG = False


Load static file when debug = False

When debug is False, django won’t load the static files

There is an extra option to be used with runserver command which forces Django to serve static files even when DEBUG=False

python runserver --insecure

Django docs ref: