I have a list of selected items from a MultipleChoiceField object. After this list is created how can I filter on a Django model table so that it selects all of the items with any of the values in the list?
for example if i selected apples, oranges and strawberries, it returns all of the data from the FruitChoices table where the fruit_name is apples, or oranges, or strawberries.
from someApp.models import FruitChoices
def main(form_list):
r = FruitChoices
data = {}
for form in form_list:
data.update(form.cleaned_data)
fruits = data['fruit_list']
for item in fruits:
result = r.objects.filter(fruit_name__contains='%s' % item)
return result