On 8/29/07, Bjorn Ruud <[EMAIL PROTECTED]> wrote: > > The pool QuerySet gets re-evaluated when the count() in the loop is > run. Since one of the fields in the filter gets changed, the amount of > objects in the QuerySet will be different. If pool.count() is replaced > with len(pool) this does not happen. Is this intended behaviour? Can a > QuerySet be made immutable?
This behaviour is by design. queryset.count() actually constructs (and executes) a new 'SELECT COUNT(*) FROM table' query. This means that it will always return the current number of objects matching the query. In your case, the number of objects is changing, so count() will return a different value each time. len(queryset) returns the length of the evaluated queryset. When the queryset is evaluated for the first time, it will act as a cache, so all calls to len(queryset) will return the same value. Yours Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

