class Queue(models.Model):
# fields here, not relevant for this discussion
class Task(models.Mode):
queue = models.ForeignKey("Queue")
status = models.IntegerField(choices=STATUS_CHOICES)
I am trying to create a Queue queryset that will annotate each Queue
with the number of tasks whose queue field is pointing to that Queue
and status field has a certain value.
I don't think annotate will work for me due to me needing to count up
only tasks whose status field has a certain value. I think I might
need extra? But I'm having touble making that work.
qs = Queue.objects.extra(select={'task_open_count':"select count(*)
from taskmanager_task inner join taskmanager_queue on
taskmanager_task.queue_id = taskmanager_queue.id where
taskmanager_task.status=1"})
I know this isn't doing the right thing. This seems to be annotating
all of the resulting queues withthe total number of open tasks (I
think).
Can anyone give me a hand? Thank you!
Margie
--
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.