How to extend html file in Django

Viewed 209

I want to extend my html file with base.html from template folder inside main my project folder. When I type:

    {% extends 'base.html' %}

it gives me this:

TemplateDoesNotExist at /app/
base.html

Request Method: GET

Request URL:    http://127.0.0.1:8000/app/

Django Version: 3.0.4

Exception Type: TemplateDoesNotExist
Exception Value:    
base.html

Hope I will get some help :)

1 Answers

You need to add the template folder in your path. Right now the django does not know that the base.html exist. So do this in your settings.py.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'template')],
        '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',
            ],
        },
    },
]
Related