I have the following code:
query = Entry.objects.all()
print 'authors ' + repr([x.id for x in authors])
print 'query ' + repr(query)
print 'query ids ' + repr([x.author.id for x in query])
query.filter(author__in=authors)
print 'filtered ids ' + repr([x.author.id for x in query])
Which outputs this:
authors [2]
query [<Entry: test>, <Entry: test>]
query ids [2, 3]
filtered ids [2, 3]
Obviously, 3 is not in [2]. So, why filtered ids are [2, 3] and not just [2]?
Regards
When you call
query.filter(author__in=authors), it returns a new queryset. It does not modify the existing queryset.If you assign the new queryset to query, then you will get the result you were expecting.