annotate 可以通过计算查询结果中每一个对象所关联的对象集合,从而得出总计值(也可以是平均值或总和),即为查询集的每一项生成聚合. from django.shortcuts import render, HttpResponse from app01 import models from app01.models import Book,Author,Publisher from django.db.models import Avg,Min,Sum,Max def data_oper(…