Django 按照字段数量去重排序
items = (
XModel.objects.all()
.values(field_name)
.annotate(Count(field_name))
.order_by('-{}__count'.format(field_name))
)
items = (
XModel.objects.all()
.values(field_name)
.annotate(Count(field_name))
.order_by('-{}__count'.format(field_name))
)