I am working on Django and I need to filter records eg:
table: Person
name | age |
---|---|
David Abraham Benj | 18 |
so, if I run this, Person.objects.filter(name__icontains="David Abraham")
it is working
but if I run this, Person.objects.filter(name__icontains="David Benj")
it is not working
any idea how it works?
framework: Django and SQL: Postgres
2
Answers
Which equal to
So, it doesn’t match the query. So, it’s expected behavior.
You need to use Q objects in order to chain multiple SQL
ILIKE
operations, which is what the__icontains
operator produces in the backgroud.Try this: