Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Field Lookups - in


Example

Get all records where firstname is one of the values in the list:

mydata = Member.objects.filter(firstname__in=['Tobias', 'Linus', 'John']).values()
Run Example »

Definition and Usage

The in lookup is used to get records where the value is one of the values in an iterable (list, tuple, string, queryset).

The in lookup is case sensitive.


SQL Equivalent

The SQL equivalent to the example above will be:

WHERE firstname IN ('Tobias', 'Linus', 'John');

Syntax

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

fieldname__in=[value1,value2,value3,...]