Django Can't Find My Templates


I'm running Python 2.6.1 and Django 1.2.1 on Windows XP SP3. I'm using JetBrains PyCharm 1.0 to create and deploy my Django apps.

I'm relatively inexperienced with Python, and I'm starting to learn Django by following along with "Writing Your First Django App" from the web site - the poll application. I'm stuck on part 3.

Everything is fine when I add the simple callback functions for "Writing your first view".

I hit the snag when I get to "Write views that actually do something."

I followed the instructions to modify the index view:

  1. Add a new method to (Note - template is ready from 'polls/index.html'):
  2. Add index.html template to site-templates/polls/ folder
  3. Modify to point to site-templates folder

Here's the code in my

from django.template import Context, loader
from polls.models import Poll
from django.http import HttpResponse

def index(request):
    latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
    t = loader.get_template('polls/index.html')
    c = Context({
        'latest_poll_list': latest_poll_list,
    return HttpResponse(t.render(c))

Here's the line in my

TEMPLATE_DIRS = ('/site-templates/')

But still I get this message when I run:

TemplateDoesNotExist at /polls/
Request Method: GET
Request URL:    http://localhost:8000/polls/
Django Version: 1.2.1
Exception Type: TemplateDoesNotExist
Exception Value:    

The exception is thrown in My debug settings look like this:

('django.core.context_processors.auth', 'django.core.context_processors.request')
('django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader')

My directory structure looks like this:

alt text

What did I miss? Is the incorrect? Please advise.

10/31/2010 9:04:25 PM

I was faced to the same problem. The mistake in my case was, that the 'app' was not in the INSTALLED_APPS list at the project file.

The error raise an error message they suggests similar error.

line 25, in get_template TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: authControll/index.html --> Application definition

7/24/2017 9:16:02 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow