Mytable.objects.using(‘default’).filter(name__contains=’dong’) <=>和like差很少(严格) python
Mytable.objects.using(‘default’).filter(name__icontains=’dong’) <=>和like差很少(忽略da xiao) 数据库
Mytable.objects.using(‘default’).filter(name=’dong’).order_by(time)/.order_by(-time) 按照全部name=dong的time属性排序/反向排序gt, gte, lt, and lte express
gt,gte, lt,lte 分别是 大于, 大于或等于, 小于, 小于或等于 django
create table test(id int not null primary key auto_increment, …)建立test表 id 主键,自增 ui
in 包含在列表里面 spa
Entry.objects.filter(id__in=[1, 3, 4])
startswith 以什么什么开头
Entry.objects.filter(headline__startswith='Will') istartwith是不区分大小写,
以什么结尾 code
range在一段范围内 orm
You can use range anywhere you can use BETWEEN in SQL for dates, numbers, and even characters. 对象
year, month, and day 严格匹配年月日 排序
>>> Entry.objects.order_by('headline')[0]
This is roughly equivalent to:
>>> Entry.objects.order_by('headline')[0:1].get()
Note, however, that the first of these will raise IndexError while the second will raise DoesNotExist if no objects match the given criteria. See get() for more details.
F 把字段去出来
from django.db.models.expressions import F
XXXXXX.update(agree=F('agree')-1)