diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2020-05-13 14:44:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-13 14:44:10 +0200 |
| commit | 01a381cc17e6747e1d9e7b95a39e885029fd2a81 (patch) | |
| tree | 9b6bf7f52db34be18c9c77ecfcbf8dacc26e1074 | |
| parent | 49ae7ce50a874f8a04cd910882fb9571ff3a0d7a (diff) | |
Fixed #31580 -- Added error messages on distinct() following union(), intersection(), and difference().
| -rw-r--r-- | django/db/models/query.py | 1 | ||||
| -rw-r--r-- | tests/queries/test_qs_combinators.py | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index e0eeccefa6..5c70229263 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 1d159e1fed..d2e7d2b80d 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', |
