[Answered ]-Django search where database value is part equal to search value

1👍

You can try this solution and you will get all the models that its name contains "Computer" or "Solutions":

import operator
from django.db.models import Q
from functools import reduce

search_value = 'Computer Solutions'
model.objects.filter(reduce(operator.or_, (Q(name__icontains=x) for x in search_value.split(" "))))

Leave a comment