To filter a Python Django query with a list of values, we can use the filter
method with in
.
For instance, we write
Blog.objects.filter(pk__in=[1, 4, 7])
to search Blog
entries with pk
set to 1,4 or 7 by calling Blog.objects.filter
with the pk_in
argument set to [1, 4, 7]
.