mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #23664 -- Provided a consistent definition for OrderedSet.__bool__
This also defines QuerySet.__bool__ for consistency though this should not have any consequence as bool(qs) used to fallback on QuerySet.__len__ in Py3.
This commit is contained in:
parent
2e5b2c612e
commit
b962653060
3 changed files with 19 additions and 3 deletions
|
@ -162,10 +162,13 @@ class QuerySet(object):
|
|||
self._fetch_all()
|
||||
return iter(self._result_cache)
|
||||
|
||||
def __nonzero__(self):
|
||||
def __bool__(self):
|
||||
self._fetch_all()
|
||||
return bool(self._result_cache)
|
||||
|
||||
def __nonzero__(self): # Python 2 compatibility
|
||||
return type(self).__bool__(self)
|
||||
|
||||
def __getitem__(self, k):
|
||||
"""
|
||||
Retrieves an item or slice from the set of results.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue