django-nonrel 谷歌应用引擎 order_by('?')
我正在 Google App Engine 中开发 django-nonrel 应用程序。
我正在尝试以随机顺序从数据库返回项目。因此,我的 Items 模型中可能有 100 个项目。我希望退回随机选择的 20 件商品。
我尝试过使用:
Items.objects.order_by('?')[:20]
除了我收到以下错误:
Randomized ordering isn't supported by the backend
我认为这是 django-nonrel 对 GAE 的限制?
是否有其他方法可以用于 GAE 上的 django-nonrel 以获得相同的效果?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经设法找到解决方法。
我只是使用 python 的 random.shuffle(LIST_ITEM) 作为执行此操作的方法。
最后其实很简单。
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.