I am trying to filter out a queryset based on if one of its field names is in a list of lower case values. The trouble is that some of these field values have capital letters, so I can't do
all_listings = all_listings.objects.filter(make__name__in=makes)
Is there a possible way to say something along the lines of
all_listings = all_listings.objects.filter(make__name__lower__in=makes)
You can try to use Lower func
from django.db.models.functions import Lower
all_listings = all_listings.objects.annotate(name_lower=Lower('make__name')).filter(name_lower__in=makes)
You can do
all_listings = all_listings.objects.filter(make__name__iregex=r'(' + '|'.join(makes) + ')')