Re: Boolean test on queryset

2011-11-28 Thread Ian Clelland
On Monday, November 28, 2011, Adam Nelson wrote: > Jirka, > That doesn't solve the problem. That will still do a very expensive count() operation on the queryset. In fact, examples.count() is what happens when you do bool(examples) anyway. I'm confused here -- examples.count()

Re: Boolean test on queryset

2011-11-28 Thread Adam Nelson
Jirka, That doesn't solve the problem. That will still do a very expensive count() operation on the queryset. In fact, examples.count() is what happens when you do bool(examples) anyway. Thanks, Adam On Mon, Nov 28, 2011 at 8:11 PM, Jirka Vejrazka wrote: > Hi Adam,

Re: Boolean test on queryset

2011-11-28 Thread Jirka Vejrazka
Hi Adam, I tend to use: if examples.count(): ...something... HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send

Boolean test on queryset

2011-11-28 Thread Adam Nelson
When one tests for the boolean value of a queryset in the following way: examples = Example.objects.all() if examples: . do something You might think (I did) that Django will call a __nonzero__ special attribute that would either execute an EXISTS SQL STATEMENT or a SELECT statement