Change for loop to self.first()
This commit is contained in:
parent
dfdecef8e7
commit
ee0c7fd8bf
@ -157,11 +157,7 @@ class BaseQuerySet(object):
|
|||||||
def _bool(self):
|
def _bool(self):
|
||||||
""" Avoid to open all records in an if stmt """
|
""" Avoid to open all records in an if stmt """
|
||||||
|
|
||||||
for value in self:
|
return False if self.first() is None else True
|
||||||
self.rewind()
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def __nonzero__(self):
|
def __nonzero__(self):
|
||||||
""" Same behaviour in Py2 """
|
""" Same behaviour in Py2 """
|
||||||
|
@ -3834,8 +3834,8 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
raise AssertionError('There is data, but cursor returned False')
|
raise AssertionError('There is data, but cursor returned False')
|
||||||
|
|
||||||
queryset.next()
|
queryset.next()
|
||||||
if queryset:
|
if not queryset:
|
||||||
raise AssertionError('There is no data left in cursor')
|
raise AssertionError('There is data, cursor must return True')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user