On Fri, Oct 7, 2011 at 10:39 AM, Jacob Kaplan-Moss <ja...@jacobian.org> wrote:
>> *Sometimes* the first works and I don't know why.
>
> This is because `MyModel.objects.all()` isn't a list; it's a QuerySet.
> That is, `MyModel.objects.all()` *doesn't* hit the database until you
> say `x[3]`, at which point Django performs a query with a LIMIT and
> OFFSET to just select that 3rd item. The entire list is never fetched.

... and the QuerySet is free to override its own internal cache
anytime it wants.  You know that `x[3]` will refer to the same
database record, but there's no guarantee that it will be the same
Python object.

-- 
Javier

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to