Re: Select all users that have undone jobs (select, groupby, count)

2011-08-29 Thread christian.posta
Try something like this: users = User.objects.filter(job__done=False).annotate(Count('job')) Then each object returned will be a 'User' object with a property named 'job__count' ex: users[0].job__count On Aug 29, 5:17 am, muzhig wrote: > Hello! > I have model

Re: Select all users that have undone jobs (select, groupby, count)

2011-08-29 Thread Babatunde Akinyanmi
I think the best way is to create a custom manager for the job (check the documentation for details-managers). In the manager, do a query that gets all the users with undone jobs by using the filter option (also see the documentation - making queries). From the resulting querydict you could count

Select all users that have undone jobs (select, groupby, count)

2011-08-29 Thread muzhig
Hello! I have model Job, that is linked to User. Job has flag `done` that indicates progress of this job. How to select list of all users, that have undone jobs, annotated by count of this undone jobs? I need this dict: { user1: 4, user2:12 } -- You received this message because you are