Reputation: 16546
trying to gather a collection of objects:
set = [model1].objects.all().filter([model2]__in=[model3].[model2]_set)
but I get a
TypeError at [url]
'ManyRelatedManager' object is not iterable
when I try to do this. Models 2 and 3 are related via a ManyToMany field in Model 2 through a fourth model that has both models as fields.
Any obvious workarounds?
Upvotes: 0
Views: 145
Reputation: 3138
I believe your problem is in [model2]__in=[model3].[model2]_set
the correct form would be
set = [model1].objects.all().filter([model2]__in=[model3].[model2]_set.all())
Upvotes: 2