django/django — pull request #3773 by dustinfarris (2014-12-22 08:48:33+00:00)
Title: M2M __in filtering after a Count annotation

After annotating and filtering a queryset for the number of m2m related objects, subsequent filters using `__in` falsely return an empty result.

In this PR, the first test passes to demonstrated the expected behavior. The second test—which is really the same logic as the first only written differently—fails.

Also see some pdb output from my personal project to show this in action: http://dpaste.com/3JQYWTZ#line-31