Change for loop to self.first()

This commit is contained in:
Jonathan Prates 2014-05-28 13:21:00 -03:00
parent dfdecef8e7
commit ee0c7fd8bf
2 changed files with 3 additions and 7 deletions

View File

@ -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 """

View File

@ -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__':