Remove orderby in if stmt

This commit is contained in:
Jonathan Prates
2014-05-28 17:06:15 -03:00
parent ee0c7fd8bf
commit 30964f65e4
2 changed files with 60 additions and 1 deletions

View File

@@ -157,7 +157,13 @@ class BaseQuerySet(object):
def _bool(self):
""" Avoid to open all records in an if stmt """
return False if self.first() is None else True
queryset = self.clone()
queryset._ordering = []
try:
queryset[0]
return True
except IndexError:
return False
def __nonzero__(self):
""" Same behaviour in Py2 """