Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'name__iexact' mean in django model filters?

Tags:

django

filter

name_iexact keyword is a parameter we can pass to filter function in django.model. Can someone please help me understand what it does?

Map.objects.filter(name__iexact=self.cleaned_data["name"]).count()
like image 571
zjm1126 Avatar asked Dec 04 '25 15:12

zjm1126


2 Answers

It's a case insensitive match. It will retrive database records with "name" field matching self.cleaned_data["name"], while the case doesn't necessarily have to match.

You can construct those lookups appending __iexact to any field name. See the documentation for more on iexact or for list of other similar field lookups.

like image 144
Ludwik Trammer Avatar answered Dec 06 '25 17:12

Ludwik Trammer


I suspect you are using Django or some kind of ORM.

name__iexact means that you are doing a case insensitive match on the field name

check for instance http://docs.djangoproject.com/en/dev/topics/db/queries/ for more documentation on django queries.

I hope this will help you, Jerome Wagner

like image 43
Jerome WAGNER Avatar answered Dec 06 '25 18:12

Jerome WAGNER



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!