[Django]-Django: TemplateDoesNotExist error for base template

8đź‘Ť

âś…

You are using Django extends the wrong way, it should take the parent template name so do this:

{% extends "base.html" %}

EDIT

OK I see, you should use the template path like you do when you render your other templates:

Let’s say you render like this “templates/child_page.html” then you should extend the same way {% extends "templates/base.html" %}

👤Seif

0đź‘Ť

go to settings.py

your templates settings should look like this:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [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',
            ],
        },
}, ]

make sure BASE_DIR is also defined

👤pujan rai

Leave a comment