On Fri, Feb 09, 2007 at 03:11:57PM +0100, Kai Kuehne wrote:
>
> Hey!
> I wanted to select all models, but in random order:
>
> random.shuffle(Obj.objects.all())
>
> This doesn't work, error message:
>
> TypeError: object does not support item assignment
Err, why not use a random sort as...
Obj.objects.order_by('?')
ref: http://www.djangoproject.com/documentation/db_api/#order-by-fields
That way you don't use all the memory in the world, and you're letting
the database deal with the sorting.
Cheers,
--
Brett Parker
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---