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 <arseniy.pota...@gmail.com> wrote: > 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 subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.