[Python] Create a screen for HTTP status code 403/404/500 with Django

Introduction

A Django reference book ** Create a screen for HTTP status code 403/404/500 ** There is a section, even if you * runserver * or get a 404 error The customized 404 screen was not displayed.

The reason is * DEBUG = True *

To create a screen for status code 403/404/500

However, even if * runserver * is used as it is This screen is displayed. (Different from the screen I made ...)

page_not_found.png

At the bottom of the screen You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. Is displayed.

Try translating with DeepL.

`This error is displayed because you have set DEBUG = True in your Django config file. If you change this to False, Django will display the standard 404 page. ``

If * DEBUG = True *, it looks like no good.

Try setting * DEBUG = False *

settings.py


DEBUG = True

Try * runserver *.

CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False. I got an error, so I'll fix it.

settings.py


DEBUG = True

ALLOWED_HOSTS = ['127.0.0.1']

Add ʻALLOWED_HOSTS = ['127.0.0.1']` Try * runserver *.

The customized 404 screen was displayed successfully.

page_not_found_2.png

404.html


<h1>Page Not Found.</h1>

References

It was very helpful. Thank you very much.

** Display a customized 404 page in Django ** https://djangobrothers.com/blogs/django_404_page/

Recommended Posts

[Python] Create a screen for HTTP status code 403/404/500 with Django
Create a LINE BOT with Minette for Python
Create a dashboard for Network devices with Django!
Create a homepage with django
Create a Django login screen
Create a directory with python
Create a Layer for AWS Lambda Python with Docker
[Python] Create a file & folder path specification screen with tkinter
Recommendations for django, wagtail ~ Why develop a website with python ~
Create a child account for connect with Stripe in Python
Create a virtual environment with Python!
Create a Twitter BOT with the GoogleAppEngine SDK for Python
Create a social integration API for smartphone apps with Django
Create a file uploader with Django
Create a Python environment for professionals in VS Code on Windows
Create a Python execution environment for Windows with VScode + Remote WSL
Create a striped illusion with gamma correction for Python3 and openCV3
Create a color picker for the color wheel with Python + Qt (PySide)
Try to create a python environment with Visual Studio Code & WSL
Create a simple Python development environment with VS Code and Docker
Create a USB boot Ubuntu with a Python environment for data analysis
Create a Python function decorator with Class
Build a blockchain with Python ① Create a class
Create a dummy image with Python + PIL.
Create a model for your Django schedule
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
Let's create a free group with Python
Build a TOP screen for Django users
Creating a login screen with Django allauth
Create a word frequency counter with Python 3.4
A tool for easily entering Python code
Steps to create a Python virtual environment with VS Code on Windows
Create a frame with transparent background with tkinter [Python]
Specify the Django http status code and return.
Get a ticket for a theme park with python
Procedure for creating a LineBot made with Python
Create a virtual environment with conda in Python
Create a page that loads infinitely with python
Create a python3 build environment with Sublime Text3
Create a color bar with Python + Qt (PySide)
Create Nginx + uWSGI + Python (Django) environment with docker
Django with Python Tools 2.2 for Visual Studio (PTVS 2.2)
A story about implementing a login screen with django
Steps to create a Twitter bot with python
Create a new page in confluence with Python
Create a color-specified widget with Python + Qt (PySide)
Create a one-file hello world application with django
A simple to-do list created with Python + Django
Create a Photoshop format file (.psd) with python
Quickly build a Python Django environment with IntelliJ
Create a Python console application easily with Click
Create a "Hello World" (HTTP) server with Tornado
Build a python execution environment with VS Code
Django 1.11 started with Python3.6
Create a Django schedule
Create a Python module
HTTP communication with Python
Create a Python environment
Python Requests status code
Create a Todo app with Django REST Framework + Angular