diff --git a/django/db/models/query.py b/django/db/models/query.py index e0eeccefa68..5c70229263c 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -1138,6 +1138,7 @@ class QuerySet: """ Return a new QuerySet instance that will select only distinct results. """ + self._not_support_combined_queries('distinct') assert not self.query.is_sliced, \ "Cannot create distinct fields once a slice has been taken." obj = self._chain() diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py index 1d159e1fed6..d2e7d2b80d4 100644 --- a/tests/queries/test_qs_combinators.py +++ b/tests/queries/test_qs_combinators.py @@ -272,6 +272,7 @@ class QuerySetSetOperationTests(TestCase): 'annotate', 'defer', 'delete', + 'distinct', 'exclude', 'extra', 'filter',