hi al almost done with the django tutorial#4.. But my app doesnt use the html pages, n doesnt load the radio buttons and results page.. Other than those the app is displayed in the default template and shows al the pages of groups users n polls.. i have placed the html templates in templates directory which is in my app polls directory.. here is my views file..
pls help.. thnx in advance.. # Create your views here. from django.template import Context, loader #from polls.models import Poll from django.http import Http404 from django.http import HttpResponse from django.template import RequestContext from django.shortcuts import get_object_or_404, render_to_response from django.http import HttpResponseRedirect, HttpResponse from django.core.urlresolvers import reverse from polls.models import Choice, Poll #def index(request): #latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] #return render_to_response('polls/index.html', {'latest_poll_list': latest_poll_list}) def index(request): latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] t = loader.get_template('/home/hdp/mysite/polls/templates/polls/ index.html') c = Context({ 'latest_poll_list': latest_poll_list, }) return HttpResponse(t.render(c)) #def detail(request, poll_id): # try: # p = Poll.objects.get(pk=poll_id) # except Poll.DoesNotExist: # raise Http404 # return render_to_response('polls/detail.html', {'poll': p}) #def detail(request, poll_id): # return HttpResponse("You're looking at poll %s." % poll_id) #def detail(request, poll_id): # p = get_object_or_404(Poll, pk=poll_id) # return render_to_response('polls/detail.html', {'poll': p}) def detail(request, poll_id): p = get_object_or_404(Poll, pk=poll_id) return render_to_response('polls/detail.html', {'poll': p}, context_instance=RequestContext(request)) def results(request, poll_id): p = get_object_or_404(Poll, pk=poll_id) return render_to_response('polls/results.html', {'poll': p}) #def vote(request, poll_id): # return HttpResponseRedirect(reverse('poll_results', args=(p.id,))) #return HttpResponse("You're voting on poll %s." % poll_id) def vote(request, poll_id): p = get_object_or_404(Poll, pk=poll_id) try: selected_choice = p.choice_set.get(pk=request.POST['choice']) except (KeyError, Choice.DoesNotExist): # Redisplay the poll voting form. return render_to_response('polls/detail.html', { 'poll': p, 'error_message': "You didn't select a choice.", }, context_instance=RequestContext(request)) else: selected_choice.votes += 1 selected_choice.save() # Always return an HttpResponseRedirect after successfully dealing # with POST data. This prevents data from being posted twice if a # user hits the Back button. return HttpResponseRedirect(reverse('polls.views.results', args=(p.id,))) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.