python - Ormar 使用 LIKE 语句选择
问题描述
我在 Ormar 的文档中找不到使用LIKE
. 有使用的示例select_relate
,但我不需要链接表。
文档中有一个例子:
books = (
await Book.objects.select_related("author")
.filter(ormar.or_(
ormar.and_(author__name__icontains="tolkien"), # one argument == just wrapped in ()
ormar.and_(author__name__icontains="sapkowski")
))
.all()
或者
books = (
await Book.objects.select_related("author")
.filter(
(Book.author.name.icontains("tolkien")) |
(Book.author.name.icontains("sapkowski"))
))
.all()
)
这个例子使用了author
相关的表Books
,但是应该怎么做才能按字段过滤Book
呢?
解决方案
推荐阅读
- email - Google Workspace 和 CPanel:发件人在向 CPanel 用户发送电子邮件时收到 550 错误
- reactjs - 如何使用刷新令牌配置 clientMaxAge/keepAlive?(下一个认证)
- google-sheets - 用 index() 填充电子表格列?
- formik - 是的:使用必须为“Y”的单个元素验证字符串数组
- javascript - 从内容页面访问母版页控件(html:输入)不起作用
- javascript - 什么是检查值是真值还是 0 的简洁方法?
- kubernetes - 部署模板中的 Kubernetes 探针
- python-3.x - 使用 like 更改 pandas 列值
- vue.js - Vue 货币输入屏蔽
- python - 按包含的数字对一列字符串列表进行排序