我正在尝试在视图中订购一个查询集。我收到以下错误消息。请帮助。
SELECT DISTINCT ON expressions must match initial ORDER BY expressions
models.py
class Op(models.Model):
operator = models.ForeignKey(Employee, null=False)
role = models.ForeignKey(Process, null=False)
views.py
op = Op.objects.all().distinct('operator').order_by('operator__employeename')
答案 0 :(得分:0)
在 views.py :
中尝试使用此功能op = Op.objects.all().distinct('operator').order_by('operator', 'operator__employeename')