我也感觉直接拼, 上原生 sql,Google 上搜“ django model select different type ”没有什么太好的结果
wph95
2016-07-22 10:14:25 +08:00
types = [car, taxx ...] cars = Car.objects.filter(types_in=types) dict = {} for type in types: dict[type] = [] for car in cars: dict[car.type].append(car)