django-nonrel google app engine order_by('?')
I am working on a django-nonrel app in Google App Engine.
I am trying to return items from a database in a random order. So I might have 100 items in my Items model. I wish to开发者_高级运维 return a random selection of 20 items.
I have tried using:
Items.objects.order_by('?')[:20]
Except I get the following error:
Randomized ordering isn't supported by the backend
I take it this is a limitation of django-nonrel on GAE?
Is there an alternative method I could use for django-nonrel on GAE to get the same effect?
I've manage to find a workaround for this.
I just used python's random.shuffle(LIST_ITEM) as a way fo doing this.
It was actually very simple in the end.
精彩评论