[Django]-Django, Template not found

2👍

You have to create templates folder on same level of app not in the app, and set TEMPLATES variable in settings.py

settings.py

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',
            ],
        },
    },
]

Now, you can add index.html in templates folder or you can add index.html file in an appropriate folder and add that folder in the templates folder. Folder structure is like below…

 app_1
   |
   |
 app_2
   |
   |
templates
   |
   |__index.html

2👍

Check whether you have added the template_dir, if not add this in your settings.py below the BASE_DIR

TEMPLATE_DIR = os.path.join(BASE_DIR,'templates')

and find templates and dirs as a dictionary file in the settings.py, add this

DIRS = [TEMPLATE_DIR,]

or directly you can add in DIRS like this

DIRS = [os.path.join(BASE_DIR,'templates')]

and make sure the directory name is templates not template according to my answer

Leave a comment