Opened 10 years ago

Closed 10 years ago

#23000 closed Bug (invalid)

Wrong path when refereing to the index.html template

Reported by: maximo.martinez@… Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

When updating the view in order to reference the newly created template. Loader is asked to load 'polls/index.html'. However, it throws an exception. Since it's looking for it in the projects folder. It's supposed to be 'index.html'.

from django.http import HttpResponse
from django.template import RequestContext, loader

from polls.models import Poll

def index(request):
    latest_poll_list = Poll.objects.order_by('-pub_date')[:5]
    template = loader.get_template('polls/index.html')
    context = RequestContext(request, {
        'latest_poll_list': latest_poll_list,
    })
    return HttpResponse(template.render(context))

Change History (1)

comment:1 by Claude Paroz, 10 years ago

Resolution: invalid
Status: newclosed

If you follow the instructions about the location of the new template, there is no problem.

"Within the templates directory you have just created, create another directory called polls, and within that create a file called index.html. In other words, your template should be at polls/templates/polls/index.html."

Note: See TracTickets for help on using tickets.
Back to Top