Friday, August 1, 2014

Going throught the Django tutorial help pls

I have:

Enter code here...from django.shortcuts import render
from django.template import RequestContext, loader
from django.http import HttpResponse

from polls.models import Poll

def index(request):
    latest_poll_list
= Poll.objects.get(name="Test") #Poll.objects.all().order_by('-pub_date')[:5]    context = {'latest_poll_list': latest_poll_list}
   
return render(request, 'polls/index.html', context)

def detail(request, poll_id):
   
try:
        poll
= Poll.objects.get(pk=poll_id)
   
except Poll.DoesNotExist:
       
raise Http404
   
return render(request, 'polls/detail.html', {'poll': poll})

def results(request, poll_id):
   
return HttpResponse("You're looking at the results of poll %s." % poll_id)

def vote(request, poll_id):
   
return HttpResponse("You're voting on poll %s." % poll_id)

It currently shows a list of the polls, what I am trying to work out is how to print out the integer value that is associated with that pole.

latest_poll_list = Poll.objects.get(name="Test")


Thankyou

MC

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/172c763e-fc5c-42d5-8429-eb0643fdcdab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment