On 14 Lis, 23:20, Nagy Károly <char...@rendszergazda.com> wrote: > Please help me in orm level filtering many-to-many relations. > > I have to filter all "authors" who does not belongs to any "articles". > Or the opposite of this, list of orphaned articles... > > I dont want to write sql in the model if possible.
How about something like this (should work, although I haven't checked it): Author.objects.annotate(article_num=Count('articles')).filter (article_num=0) - where articles=ManyToManyField('Article') -- Tomasz Zieliński http://pyconsultant.eu -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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=.