Can I test for count of a many to many field, in a Q query, along with other filters?

8 views
Skip to first unread message

Mark London

unread,
Jan 16, 2018, 7:02:24 PM1/16/18
to Django users
If I'm creating a query using Q, can I make one of Q tests, be a count of a manytomany field?    I.e., one of the Q filters, should test to see if a specific manytomany field, has a count greater than 5,   I know that I can use annotate to test for count.   But can annotate be specified within a Q query?   

If not, can I make 2 separate queries, and combine them, and eliminate duplicates?

Thanks! - Mark 
Reply all
Reply to author
Forward
0 new messages