I have a list of names, e.g.:
name_list = ['Alpha', 'bEtA', 'omegA']
Currently I have the following queryset:
MyModel.objects.filter(name__in=name_list)
I would like to be able to filter the names in a case-insensitive fashion. My first thought was to use the iexact
field lookup but it doesn't seem to work with in
. How can I use the iexact
with the in
field lookup for my queryset? Or is there an alternate way to perform this query?
Here's my solution, which uses Q objects instead:
Ok I test it and it works :)