#STEP 1: Create your custom 404.html template in your template folder
#STEP 2: In your views create a new view function
def error_404_handler(request, exception):
return render(request, 'crypto/404.html')
#STEP 3: Go to your url.py file in your project file and add this
from django.conf.urls import handler404
handler404 = 'appname.views.error_404_handler'
#STEP 4: In your setting.py change these settings
DEBUG = FALSE
ALLOWED_HOSTS = ['*'] #Do not use in production
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]