Diango

Diango 数据库操作API:

 

类型描述
exact精确匹配: polls.get_object(id__exact=14).
iexact忽略大小写的精确匹配: polls.objects.filter(slug__iexact="foo") 匹配 fooFOOfOo, 等等.
contains大小写敏感的内容包含测试: polls.objects.filter(question__contains="spam") 返回question 中包含 "spam" 的所有民意测验.(仅PostgreSQL 和 MySQL支持. SQLite 的LIKE 语句不支持大小写敏感特性. 对Sqlite 来说, contains 等于 icontains.)
icontains大小写不敏感的内容包含测试:
gt大于: polls.objects.filter(id__gt=4).
gte大于等于.
lt小于.
lte小于等于.
ne不等于.
in位于给定列表中: polls.objects.filter(id__in=[1, 3, 4]) 返回一个 polls 列表(ID 值分别是 1或3或4).
startswith大小写敏感的 starts-with: polls.objects.filter(question__startswith="Would"). (仅PostgreSQL 和MySQL支持. SQLite 的LIKE 语句不支持大小写敏感特性. 对Sqlite 来说,``startswith`` 等于 istartswith)
endswith大小写敏感的 ends-with. (仅PostgreSQL 和 MySQL)
istartswith大小写不敏感的 starts-with.
iendswith大小写不敏感的 ends-with.
range范围测试: polls.objects.filter(pub_date__range=(start_date, end_date)) 返回 pub_date 位于 start_date 和 end_date (包括)之间的所有民意测验
year对 date/datetime 字段, 进行精确的  匹配: polls.get_count(pub_date__year=2005).
month对 date/datetime 字段, 进行精确的  匹配:
day对 date/datetime 字段, 进行精确的  匹配:
isnullTrue/False; 做 IF NULL/IF NOT NULL 查询: polls.objects.filter(expire_date__isnull=True).

转载于:https://www.cnblogs.com/cocoa-z/p/6903786.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值