I have models:
ModelA, Conversation
class ModelA:
conversations = models.ManyToManyField(Conversation)
I want to retrieve records of ModelA which has conversations with ids 1,2,3 (lets say).
I tried this:
ModelA.objects.filter(conversations__id__in=[1,2,3])
But this is not doing exact filter. If record A has only one conversation with id 1, record B with only one conversation with id 2 and record C has 3 conversations with ids 1,2,3, then above code returning all 3 records. But, I want to retrive only record C becaus only that has all the conversations 1,2,3.
I need exact or if possible subset. I mean, If I search for [1,2] then record A, B shouldn't come but record C can come([1,2] is subset of [1,2,3])
Please let me know if not clear.