[ACCEPTED]-Django: Filtering on the related object, removing duplicates from the result-duplicates
Adding .distinct()
will give you only distinct results.
0
See the QuerySet API Docs for the "distinct()" function:
Returns 11 a new QuerySet that uses SELECT DISTINCT 10 in its SQL query. This eliminates duplicate 9 rows from the query results.
By default, a 8 QuerySet will not eliminate duplicate 7 rows. In practice, this is rarely a problem, because simple 6 queries such as Blog.objects.all() don't 5 introduce the possibility of duplicate 4 result rows. However, if your query spans 3 multiple tables, it's possible to get 2 duplicate results when a QuerySet is evaluated. That's 1 when you'd use distinct().
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.