Suppose I have a queryset of animals and I want to write a query that determines if a manytomany field on another model has at least one object in common with the animals queryset. How can this be acheived?
farm_animals = Animals.objects.filter(name__in=["Dog", "Cow", "Horse"])
print farm_animals # [<Animal: Dog>, <Animal: Cow>, <Animal: Horse>]
# Returns all people who have at least one farm animal.
people_with_a_farm_animal = People.objects.filter(???)
This seems like it should be easy to do, but I'm struggling to find a good efficient way to do it. Thanks in advance for any help.