>You originally say the model1 > has a foreign key to model2 - I interpret that to mean that the > ForeignKey is defined on model1. However, your code references > model1.model2_set - which would imply that the FK is defined on > model2, pointing to model1. So, do you want the objects that are > pointed to by FKs from objects in the initial list, or the ones that > FKs in the initial list point to? > > > return_list = Model1.objects.filter(model2__in=model2_list)
Sorry, the ForeignKey is defined on model2. I need to get all the model1 objects that is in the given modelList and is used as a foreignkey in a model2 object. Your suggestion assumes that the input is a model2_list, but the modelList is model1 objects. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

