Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to custom page not found in django

#STEP 1: In your template folder create a new html file named 404.html and with custom style of whatever you want
#STEP 2: Go to your setting.py and change debug to false also adding your domain names

DEBUG = FALSE
ALLOWED_HOSTS = ['*'] #NEVER USE THIS IN PRODUCTION!!!!!

#STEP 3: Add the template path to your template directory
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',
            ],
        },
    },
]

#STEP 4: If you get and error that says: ValueError: Missing staticfiles manifest entry for 'admin/css/base.css' Then run 'python manage.py collectstatic' locally and make sure {% load static %} is at the of your html file'''
		
 
PREVIOUS NEXT
Tagged: #custom #page #django
ADD COMMENT
Topic
Name
8+3 =