What do the "name__icontains" and "description__icontains" arguments mean in the Django request filter?

maps = (maps.filter(name__icontains=search_terms) |
            maps.filter(description__icontains=search_terms))

I cannot find the meaning of these filter arguments.

+7
source share
2 answers

This is a case-sensitive containment test .

Example:

Entry.objects.get(headline__icontains='Lennon')

SQL equivalent:

SELECT ... WHERE headline ILIKE '%Lennon%';

In your case, the code says that maps should matter Trueif the name or description field contains a value search_terms.

+12
source

xxx_icontainsSearches the entire field xxxfor the case insensitive argument.

http://docs.djangoproject.com/en/1.1/ref/models/querysets/#icontains

+1
source

All Articles