X_X I can't believe I didn't even think of that. Thanks maiyte On 12/23/11, Nan <ringe...@gmail.com> wrote: > Try Python's slicing syntax. [1] > > [1] > https://docs.djangoproject.com/en/dev/topics/db/queries/#limiting-querysets > > On Dec 23, 2:16 pm, Babatunde Akinyanmi <tundeba...@gmail.com> wrote: >> Hello, >> How can I get the ORM to do the equivalent of this sql query with the >> result being a QuerySet: >> >> SELECT * FROM table LIMIT expr. >> >> I know I can use objects.raw() but I need to shuffle the results and >> RawQuerySet objects do not have __len__() making it impossible to >> random.shuffle. >> >> I actually have a database with thousands of records from which I have >> to randomly select just 10 records from the thousands during every >> query. Because of efficiency, I use the normal select with limit query >> using a random number as offset and 200 as the limit. Next, the idea >> is to shuffle the results and use the first 10 numbers. >> >> Thanks for any assistance >> >> -- >> Sent from my mobile device > > -- > 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. > >
-- Sent from my mobile device -- 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.