id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 28560 distinct() on ordered queryset with restricted list of columns returns incorrect result Mariusz Felisiak "When `distinct()` is used with `values()` (or `values_list()`) on ordered queryset and a list of fields in `values()` doesn't contain all fields from `ORDER BY`, then it doesn't return correct result because columns from `ORDER BY` clause must be included in `SELECT`. After some discussion on the mailing list (https://groups.google.com/g/django-developers/c/DNVRFqVBsfk/m/xDUvaq3DAAAJ) it looks like the consensus is to require an explicit opt-in or raise an error (i.e., never add a column implicitly if the user specified a list of columns via values() or values_list())." Bug new Database layer (models, ORM) dev Normal distinct values Accepted 0 0 0 0 0 0