On Mar 16, 2011, at 8:49 AM, Margie Roginski wrote:
> Hmmm ... so I just got back to trying this and I actually don't think
> the annotate call as suggested does what I am looking for. Say I want
> to annotate queues with the number of closed tasks. This call:
>
> Queue.objects.filter(task__sta
Right again! I agree what you are saying works. I tried to take it a
step further and OR together two querysets. I was then looking at the
results of that OR, and it was not what I expected. One qs had been
annotated with num_tasks_open, the other had been annotated with
num_tasks_closed. I wa
On Wed, Mar 16, 2011 at 3:49 PM, Margie Roginski
wrote:
> Hmmm ... so I just got back to trying this and I actually don't think
> the annotate call as suggested does what I am looking for. Say I want
> to annotate queues with the number of closed tasks. This call:
>
> Queue.objects.filter(task__s
Hmmm ... so I just got back to trying this and I actually don't think
the annotate call as suggested does what I am looking for. Say I want
to annotate queues with the number of closed tasks. This call:
Queue.objects.filter(task__status=Task.STATUS_CLOSED).annotate(num_tasks=Count('task'))
finds
Ah, right - so obvious! I'm not sure why it didn't occur to me to
filter first, then annotate. Thank you!
On Mar 15, 2:43 am, Tom Evans wrote:
> On Mon, Mar 14, 2011 at 8:57 PM, Margie Roginski
>
> wrote:
> > class Queue(models.Model):
> > # fields here, not relevant for this discussion
>
>
On Mon, Mar 14, 2011 at 8:57 PM, Margie Roginski
wrote:
> 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 query
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 que
7 matches
Mail list logo