final_pred = Q() for pred in [Q(name__icontains=keyword) for keyword in keywords.split(' ')]: final_pred = final_pred | pred; Table.objects.filter(final_pre)