ManyRelatedManager对象不可迭代

试图做到这一点:

更新:

wishList = WishList.objects.get(pk=20) matches = [val for val in Store.attribute_answers.all() if val in wishList.attribute_answers] 

并得到这个…

 'ManyRelatedManager' object is not iterable 

这两个领域都很多,所以怎么做呢?

尝试

 matches = [val for val in Store.attribute_answers.all() if val in WishList.attribute_answers.all()] 

听起来像你正在寻找像Store.attribute_answers.all()