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):
|
||||
""" Avoid to open all records in an if stmt """
|
||||
|
||||
for value in self:
|
||||
self.rewind()
|
||||
return True
|
||||
|
||||
return False
|
||||
return False if self.first() is None else True
|
||||
|
||||
def __nonzero__(self):
|
||||
""" Same behaviour in Py2 """
|
||||
|
@ -3834,8 +3834,8 @@ class QuerySetTest(unittest.TestCase):
|
||||
raise AssertionError('There is data, but cursor returned False')
|
||||
|
||||
queryset.next()
|
||||
if queryset:
|
||||
raise AssertionError('There is no data left in cursor')
|
||||
if not queryset:
|
||||
raise AssertionError('There is data, cursor must return True')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user