from itertools import chain from operator import attrgetter # 拿到多条queryset queryset1 = model.objects.filter(status=1).all() queryset2 = model.objects.filter(status=2).all() # 将上面两组查询结果合并, 并设置排序方式: -create_time new_queryset = sorted(chain(queryset1, queryset2), key=attrgetter('-create_time'), reverse=True)
标签:chain,queryset,多条,Django,attrgetter,queryset1,排序 From: https://www.cnblogs.com/chaoqi/p/17860145.html