Django TemplateDoesNotExist Error on Windows machine
Question: I have been following the tutorial for Django **[Tango with
Django](http://www.tangowithdjango.com/book17/chapters/setup.html#django-
basics)**

I was trying to add a template as instructed on the
[link](http://www.tangowithdjango.com/book17/chapters/templates_static.html).
I am working with Python 2.7, Django 1.8 on a windows 7 machine.

Below is the error that I get:

    
    
    TemplateDoesNotExist at /rango/
    rango/index.html
    Request Method: GET
    Request URL:    http://127.0.0.1:8000/rango/
    Django Version: 1.8
    Exception Type: TemplateDoesNotExist
    Exception Value:rango/index.html
    Exception Location: C:\Python27\lib\site-packages\django\template\loader.py in get_template, line 46
    

* * *
    
    
    Django tried loading these templates, in this order:
    Using loader django.template.loaders.filesystem.Loader:
    Using loader django.template.loaders.app_directories.Loader:
    C:\Python27\lib\site-packages\django\contrib\admin\templates\rango\index.html (File does not exist)
    C:\Python27\lib\site-packages\django\contrib\auth\templates\rango\index.html    (File does not exist)
    

Below is my file structure:

    
    
    tango_with_django_project
    +-- rango
    |   +--views.py
    |   +--other files
    +-- tango_with_django_project
    |   +--templates
    |   |   +--rango
    |   |   |  +--index.html
    |   +--settings.py
    |   +--other files
    +-- db.sqlite3
    +-- manage.py`
    

I have given the template path as below in **`settings.py`** :

    
    
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    TEMPLATE_PATH = os.path.join(BASE_DIR,'templates')
    TEMPLATE_DIRS = (
        TEMPLATE_PATH,
    )
    

And have set the view as in **`views.py`** :

    
    
    from django.shortcuts import render
    from django.http import HttpResponse
    
    def index(request):
       context_dict = {'boldmessage': "I am bold font from the context"}
       return render(request, 'rango/index.html', context_dict)
    

Without using the template, it works fine and displays plain text. But when I
do the changes required for the template, it does not work and throws the
Error. There are many links on SO with the same issue but none have worked for
me. The [one](http://stackoverflow.com/questions/14150341/django-the-
templatedoesnotexist-error) with almost the same Error description and on
Windows machine has a vague answer.

I have tried directly specifying the **absolute path** instead of getting it
from `os.path` and have also tried placing the template folder in different
paths.

Any help would be appreciated.


Answer: The solution that worked for me was removing the below piece of code from
`settings.py`:

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

And adding : ` TEMPLATE_DIRS =
('C:/Users/vaulstein/tango_with_django_project/templates',)`

**OR**

Changing the line 4th line below :

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

