On Sat, 2006-05-20 at 02:08 -0700, [EMAIL PROTECTED] wrote:
> Jacob,
> 
> thanks. That does indeed sound easy.
> 
> But -- just so I understand -- I would assume that what this does is
> fetch all Photos, in random order, then take the first ten and throuw
> the rest away (to be garbage-collected). I'd assume the [:10] to be
> applied only after everything's been loaded.

That is not the case. Querysets (that Photo.objects.order_by('?')
sucker) have splice overridden so that it produces offset and limit
clauses in the SQL. So the '[:10]' bit just adds "LIMIT 10" to the SQL
query.

See
http://www.djangoproject.com/documentation/db_api/#limiting-querysets
for some more examples.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to