ManyRelatedManager对象不是可迭代
问题描述:
试图做到这一点: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()