Ответ 1
Try
matches = [val for val in Store.attribute_answers.all() if val in WishList.attribute_answers.all()]
Попытка сделать это:
Обновлено:
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
Оба поля многообразны, так как это можно сделать?
Try
matches = [val for val in Store.attribute_answers.all() if val in WishList.attribute_answers.all()]
звучит так, будто вы ищете что-то вроде Store.attribute_answers.all()
Для всех парней, которые находят код чтения в вопросах как TL; DR
Вместо query_set.many_to_many
Вы должны использовать query_set.many_to_many.all()
если вы делаете это в шаблоне
{% for room in study.room_choice.all %}
{{ room }}
{% empty %}
empty list!
{% endfor %}
Здесь busines_type - это Foreign_key в профильной модели.
pro = Profile.object.filter(user=myuser).first()
business_type = pro.business_type.all()
if business_type:
b_type = ''
for b in business_type:
b_type += str(b.type)+' '
a = b_type