I hope it is not a little trivial my question I have the following models.
class ModelA(models.Model):
tipo= UCharField(max_length=20, null=True, blank=True)
class ModelB(models.Model):
model_a= models.ForeignKey(ModelA, null=False, blank=False,related_name='modelA_%(class)s_objects')
I need to obtain the records contained in the following array:
list_id= list(ModelA.objects.filter(tipo= 1).values_list('id', flat=True))
ModelB.objects.filter(modal_a_id__in = list_id)
It turns out that "IN" returns if it found any of the values of the array, I require that it yield results when all the ids of the array are contained in the ModelB model. I could do an iteration for each value in the array and check if it exists, any suggestions to do it in a simpler way ??