On Thu, May 21, 2009 at 5:10 AM, Chris Withers <[email protected]> wrote:
> What was your solution in the end? I'm always interested this kind of
> batching of results, and I'm very new to Django...

The Django tutorial mentions this -- a Django QuerySet is "lazy",
which means that it doesn't do a query until it absolutely has to. So,
for example, simply writing "SomeModel.objects.all()" doesn't
immediately execute the query -- you can tack filters and whatnot onto
it, and all they'll do is refine the query that eventually gets
executed. In this specific case, slicing a QuerySet (e.g.,
"SomeModel.objects.all()[:5]" or whatever) will just add a LIMIT
clause to the query that gets executed, rather than retrieving all the
objects and then plucking a few out.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to