Hi,
Considering the following models (simplified time-tracking app):
---------------------------------------------
class Objective(models.Model):
pass
class Task(models.Model):
status = models.IntegerField()
objective = models.ForeignKey(Objective, related_name='tasks')
---------------------------------------------
I can retrieve Objective objects, each with a count of associated
tasks, using annotation/aggregation:
Objective.objects.annotate(count_tasks=Count('objective__tasks'))
What I would like to do, however, is the following:
Retrieving Objective objects, each with a count of completed tasks and
remaining tasks (i.e grouping by their status).
Can this be done 'natively' using Django querysets?
Thanks for any hint (sorry, my SQL skills are not even sharp enough to
translate this requirement with raw 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
-~----------~----~----~----~------~----~------~--~---