Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k 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.7k points)

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

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

Browse Categories

...