Friday, August 1, 2014

Re: Going throught the Django tutorial help pls



On Saturday, 2 August 2014 12:55:25 UTC+10, Collin Anderson wrote:
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.

Is poll.id what you want? In the template it would be {{ poll.id }}

Or: Poll.objects.get(name="Test").id

So I tried:

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

 and get a error, sorry I am really new to both python and SQLite

I do have a poll "Test"

Thank you

Mick C

--
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/850a42a7-eebd-44f1-a2bf-e1bcabc0c952%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment