[Answered ]-Django annotate usage over an model instance other than query item

2👍

Use aggregate:

e.companyreview_set.aggregate(overall_value = Sum('overall_rating'))

For:

class Employer(models.Model): 
     name = models.CharField(max_length=100)

class CompanyReview(models.Model): 
     employer = models.ForeignKey(Employer)
     overall_rating = models.IntegerField()    
👤Udi

Leave a comment