[Fixed]-TemplateDoesNotExist at / base.html

20πŸ‘

βœ…

I’m not familiar with the book you are using, so I can’t give you any advice based on that. If the book is for Django 1.7, you will find it easier to use Django 1.7 instead of Django 1.8, at least when you are beginning with Django.

If you want to stick with Django 1.8, here’s how to fix the error you are currently seeing:

Your settings.py file has a mixture of old templates settings, like TEMPLATE_DIRS and TEMPLATE_LOADERS (Django <= 1.7), and the new settings under TEMPLATES (Django 1.8+).

First, remove the old settings TEMPLATE_DIRS and TEMPLATE_LOADERS.

Secondly, it looks as if DIRS is incorrect in your TEMPLATES setting.

Define BASE_DIR, which should be included in settings.py by default when you run ./manage.py startproject

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

Then change TEMPLATES to

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        ...
πŸ‘€Alasdair

2πŸ‘

I had same problem first I tried to solve it with adding path to shortcuts of HTML templates {% extends "base.html" %} to {% extends "foldername/template/base.html" %} it did not work.

After that I add to β€˜base.html’ file in every projects templates folder. It worked for me.

πŸ‘€R.Sinan

0πŸ‘

In installed apps add mytweets instead of tweets .

πŸ‘€Faraz

0πŸ‘

I had exactly that problem, base.html not found in my_project/templates/base.html.

I fixed it moving the directory templates just after the app that calls it
(before buggy)

--my_project
 --templates
 --app_a
(after fixed)
--my_project
 --app_a
 --templates
πŸ‘€Emilio Zavala

-4πŸ‘

Set your template path in DIR [] of settings.py

 TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [**'C:\\Python27\\Lib\\site-packages\\django\\contrib\\admin\\templates\\admin'**],
        'APP_DIRS':True,
        'OPTIONS': {
πŸ‘€Santosh

Leave a comment