Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

I can't find the meaning of these filter arguments.

like image 364
zjm1126 Avatar asked Apr 03 '10 11:04

zjm1126


1 Answers

It's a case-insensitive containment test.

Example:

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

SQL equivalent:

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

In your case the code says maps should be True if either the name or the description field contains the value of search_terms.

like image 157
Garethr Avatar answered Sep 20 '22 02:09

Garethr