📅  最后修改于: 2022-03-11 15:03:24.393000             🧑  作者: Mango
from django.db.models import Subquery
Model.objects.filter(
pk__in=Subquery(
Model.objects.all().distinct('foo').values('pk')
)
).order_by('bar')