0 votes
1 view
in SQL by (22.4k points)

What is the equivalent of this SQL statement in Django?

SELECT * FROM table_name WHERE string LIKE pattern;

How do I implement this in Django? I tried

result = table.objects.filter( pattern in string )

But that did not work. How do I implement this?

1 Answer

0 votes
by (40.3k points)

Try using __contains or __icontains (case-insensitive) like this:

result = table.objects.filter(string__contains='pattern')

Welcome to Intellipaat Community. Get your technical queries answered by top developers !