b-rat
b-rat

Reputation: 91

Django 1.8 TEMPLATE-DEBUG = True setting sets off Template Not Found Error

DJANGO 1.8 Python 3.4

I had previously encountered the TEMPLATES array setting generating error "Template not found" when the Django template loader in fact reports that it found the template. This I was able to work around by reverting to the TEMPLATE_DIRS setting.See the Question

I needed to debug a template, so i set TEMPLATE_DEBUG to True... and it again generated the Template not found error:

index.html

Request Method: GET Request URL: http://127.0.0.1:7000/ Django Version: 1.8.2 Exception Type: TemplateDoesNotExist Exception Value:

index.html

Exception Location:     /home/sdr/sl/lib/python3.4/site-packages/django/template/loader.py in render_to_string, line 138
Python Executable:  /home/sdr/sl/bin/python
Python Version:     3.4.3
Python Path:    

['/home/sdr/sl/agryp',
 '/home/sdr/pycharm-4.5/helpers/pydev',
 '/home/sdr/sl/src/tastypie',
 '/home/sdr/sl/agryp',
 '/usr/local/lib/python34.zip',
 '/usr/local/lib/python3.4',
 '/usr/local/lib/python3.4/plat-linux',
 '/usr/local/lib/python3.4/lib-dynload',
 '/home/sdr/sl/lib/python3.4/site-packages']

Server time:    Thu, 28 May 2015 04:05:11 +0000
Template-loader postmortem

Django tried loading these templates, in this order:

    Using loader django.template.loaders.filesystem.Loader:
        /home/sdr/sl/agryp/templates/index.html (File exists)

Error persists whether I use TEMPLATES=[] setting or TEMPLATE_DIRS setting.

I would appreciate some insight in to the problem.

Upvotes: 1

Views: 1087

Answers (1)

Zealous System
Zealous System

Reputation: 2324

Make sure you have provided templates folder path in settings.py Or check your template path is correct in views.py

In Django 1.8 it will be like this

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

This worked for me.

Upvotes: 1

Related Questions