Fixed #20242 - Fixed issue with QuerySet __contains__ logic and prefetching objects

This is a pull request for ticket #20242.