sql “LIKE” equivalent in django query

前端 未结 5 1294
星月不相逢
星月不相逢 2020-12-13 05:19

What is the equivalent of this SQL statement in django?

SELECT * FROM table_name WHERE string LIKE pattern;

How do I implement this in djan

5条回答
  •  盖世英雄少女心
    2020-12-13 06:00

    contains and icontains mentioned by falsetru make queries like SELECT ... WHERE headline LIKE '%pattern%

    Along with them, you might need these ones with similar behavior: startswith, istartswith, endswith, iendswith

    making

    SELECT ... WHERE headline LIKE 'pattern%

    or

    SELECT ... WHERE headline LIKE '%pattern

提交回复
热议问题