from django.db.models import Max,Min,Count,Sum,Avg
1.aggregate 终止子句,获取数据
Ex:models.Book.objects.filter(id__gt==2).aggregate(max=Max('pirce),min=Min('price'))
2.注释函数 annocate 注释的意思
ret = models.Book.objects.annocate(Count('authors')).values().
3.F查询和Q查询
ret = models.Book.objects.filter(sale_gt=F("kucun"))
ret = models.Book.objects.filter(id__lte=3).update(sale=F('sale'*2) + 13)
4. 事务 from django.db import transaction
with transaction.automic():
models.Book.object.all().update(kucun=F('kucun')-10)
models.Book.object.all().update(sale=F('sale') + 10)