这是我的SQL查询
SELECT id, name, address, city, state_province, country, website
FROM books_publisher
WHERE name LIKE '%press' and city LIKE '%myn';
正如您在上面的代码中看到的,我已经使用and
多个like
如何在Django中执行相同的操作?我试过这个但是没有用
Mplaces.objects.filter(name__startswith='press' and city__startswith=myn)
答案 0 :(得分:2)
试试这个:
Mplaces.objects.filter(name__endswith='press', city__endswith=myn)
这里,(逗号)表示'和'和|意思是'或'
答案 1 :(得分:0)
Mplaces.objects.filter(name__endswith='press', city__endswith='myn')
SQL等价物:
SELECT ... WHERE name LIKE "%press" and city LIKE "%myn";