In your example "print qs[0]" evaluates a *clone* of "qs", not "qs" itself.
Therefore "qs[0]; qs[-1]; qs[0]" triggers 3 queries, just like "qs[0]; qs[0]; qs[0]" would. Now, if you really evaluate your "qs", for example by doing "list(qs)", then further slicing/indexing on "qs" would operate on the cached result, which internally is a plain Python list. I've put together a quick and dirty proof of concept: https://github.com/loic/django/compare/ticket13089. -- Loic On Jul 31, 2013, at 10:16 PM, Tom Evans <[email protected]> wrote: > What would it do if the query had already been evaluated? IE, how many > queries does this run? > > qs = Model.objects.filter(…).order_by(…) > print qs[0] > print qs[-1] > print qs[0] -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. For more options, visit https://groups.google.com/groups/opt_out.
