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)