My model is something like this,
class Job(models.Model): name = models.CharField(...) class Entry(models.Model): job = models.ForeignKey(Job) hrs_worked = models.IntegerField() Now I want to get the sum of the hours worked in a job which I can get by summing Entries for that job. something like entries = Entry.objects.filter(job = job) hrs_worked = 0 for entry in entries: hrs+= entry.hrs_worked Instead is there some way I can get django to do this in the database, where it runs a query like select sum(hrs_worked) from Entry where job_id = job.id, without using custom SQL? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

