Fixed #31580 -- Added error messages on distinct() following union(), intersection(), and difference().

This commit is contained in:
Hasan Ramezani 2020-05-13 14:44:10 +02:00 committed by GitHub
parent 49ae7ce50a
commit 01a381cc17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -1138,6 +1138,7 @@ class QuerySet:
""" """
Return a new QuerySet instance that will select only distinct results. Return a new QuerySet instance that will select only distinct results.
""" """
self._not_support_combined_queries('distinct')
assert not self.query.is_sliced, \ assert not self.query.is_sliced, \
"Cannot create distinct fields once a slice has been taken." "Cannot create distinct fields once a slice has been taken."
obj = self._chain() obj = self._chain()

View File

@ -272,6 +272,7 @@ class QuerySetSetOperationTests(TestCase):
'annotate', 'annotate',
'defer', 'defer',
'delete', 'delete',
'distinct',
'exclude', 'exclude',
'extra', 'extra',
'filter', 'filter',