Tutorials References Exercises Bootcamp Menu
Sign Up Create Website Get Certified Pro

Field Lookups - icontains


Do a case insensitive search for all records that have the value "ref" in the lastname column:

mydata = Member.objects.filter(lastname__icontains='ref').values()
Run Example »

Definition and Usage

The icontains lookup is used to get records that contains a specified value.

The icontains lookup is case insensitive.

For a case sensitive search, use the contains lookup.

SQL Equivalent

The SQL equivalent to the example above will be:

WHERE lastname LIKE '%ref%';


All Field lookup keywords must be specified with the fieldname, followed by two(!) underscore characters __ and the keyword: