For easy reference, models are pasted below. from django.db import models
class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() # views.py def results(request, poll_id): p = get_object_or_404(Poll, pk=poll_id) choices = p.choice_set.all() total_poll_votes = sum(c.votes for c in choices) # total votes for all choices in this poll # If i get it correctly, you want the percentage of votes for each choice? percentage = {} for choice in choices: vote = choice.votes vote_percentage = (vote/total_poll_votes)*100 # then create a mapping here percentage[choice.id] = vote_percentage As the end result, percentage will look like this: {'1':23, '2':35} -- Gladys http://bixly.com On Apr 1, 7:39 pm, cha <mohamma...@gmail.com> wrote: > ok .. i know it's the amount of votes for option > how can I get it in python -- 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.