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
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
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
3 matches
Mail list logo