hai I have two models as shown belove from django.db import models from django.db.models import Sum # Create your models here. class polls(models.Model): question = models.CharField(max_length=200) pubish_date = models.DateTimeField('Date published')
def __unicode__(self): return self.question def getCount(self): count = choice.objects.filter(polls=self.id).annotate(test=Sum('vote')) return count.test getCount.allow_tags = 'true' getCount.short_description = 'Total Answers' class choice(models.Model): polls = models.ForeignKey(polls) choice = models.CharField(max_length=200) vote = models.IntegerField() Here i need to get sum of votes for each question.So I need to edit the code in the function getCount(). I try with the above code but getting 'none'.then what may be the problem??.This is for the listing in django admin polls listing -- 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.