Http404

Based on the HTTP standards, the 404 error is supposed to be for Page Not Found, not a generic error page

Settings.py

DEBUG = False
ALLOWED_HOSTS = ['*']  # Don't Use ['*'] For Production
# ALLOWED_HOSTS = ['localhost', '127.0.0.1']

404.html

You can create an HTML template named 404.html and place it in the top level of your template tree

Usage

from django.http import Http404

def xxx(request):
    # Some Code
    raise Http404('xxx')

References

[1] Docs@DjangoProject, The Http404 exception

[2] Docs@DjangoProject, The 404 (page not found) view

results matching ""

    No results matching ""