Ticket #6899: nonzero-queryset.diff
File nonzero-queryset.diff, 1.1 KB (added by , 17 years ago) |
---|
-
django/db/models/query.py
72 72 iter(self).next() 73 73 except StopIteration: 74 74 return False 75 return True75 return bool(self._result_cache) 76 76 77 77 def __getitem__(self, k): 78 78 "Retrieve an item or slice from the set of results." -
tests/modeltests/nonzero/models.py
1 """ 2 43. Boolean evaluation of QuerySets 3 4 This tests that QuerySet.__nonzero__ behaves consistently between caching. 5 """ 6 7 from django.db import models 8 9 class Empty(models.Model): 10 pass 11 12 __test__ = {'API_TESTS':""" 13 >>> objects = Empty.objects.all() 14 >>> bool(objects) 15 False 16 >>> bool(objects) 17 False 18 """}