擅长:python、mysql、java
<p><code>.distinct([*fields])</code>仅在PostgresSQL中有效。</p>
<p>来自<a href="https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.distinct" rel="nofollow noreferrer">distinct</a>文档</p>
<p>这就是区别。对于普通的distinct()调用,当确定哪些行是不同的时,数据库会比较每行中的每个字段。对于具有指定字段名的distinct()调用,数据库将只比较指定的字段名。</em></p>
<p>如前所述,检查记录中的所有字段。大多数情况下,您可能会得到具有不同字段值的记录(更可能是在查询多个表的manytomy或ForeignKey关系时)。</p>
<p>要合并为数组,可以参考前面的问题<a href="https://stackoverflow.com/questions/12382232/django-query-distinct-values-works-but-i-cant-use-the-query-result">Django Query distinct values works but i cant use the query result</a></p>