When I am trying to apply template for views by loader module, I'm getting the following error.I want to know whether this error is due to my proxy network or error related to directories of template.
views.py is :
from django.shortcuts import render
from django.http import HttpResponse
from .models import Question
from django.template import loader
def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html')
context = {
'latest_question_list': latest_question_list,
}
return HttpResponse(template.render(context, request))
def detail(request, question_id):
return HttpResponse("You're looking at question%s"%question_id)
def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response % question_id)
def vote(request, question_id):
return HttpResponse("You're voting on question %s"%question_id)
Traceback:
>File "C:python27libsite-packagesdjangocorehandlersbase.py" in get_response
149. response = self.process_exception_by_middleware(e, request)
>File "C:python27libsite-packagesdjangocorehandlersbase.py" in >get_response
> 147. response = wrapped_callback(request, *callback_args, >**callback_kwargs)
>File "c:Python27Scriptsmysitepollsviews.py" in index
> 8. template = loader.get_template('polls/index.html')
>File "C:python27libsite-packagesdjangotemplateloader.py" in get_template
> 43. raise TemplateDoesNotExist(template_name, chain=chain)
>Exception Type: TemplateDoesNotExist at /polls/
>Exception Value: polls/index.html
Aucun commentaire:
Enregistrer un commentaire