django 排序_django-sphinx排序

django 排序

Unfortunately, the django-sphinx module is not very thoroughly documented. One thing which I could not figure out is how to do sorting. I thought that I had to set some kind of keyword argument on the SphinxSearch instance… (I have to admit though that the sorting is indeed demonstrated in the project README.rst, I simply overlooked it…)

不幸的是, django-sphinx模块没有得到充分的记录。 我不知道的一件事是如何进行排序。 我以为我必须在SphinxSearch实例上设置某种关键字参数…(我必须承认,尽管排序确实在项目README.rst中得到了证明,但我只是忽略了它……)

But the solution was much simpler – you can use order_by directly on the SphinxSearch instance.

但是解决方案要简单得多–您可以直接在SphinxSearch实例上使用order_by

 ModelModel .. searchsearch .. queryquery (( 'spam''spam' )) .. order_byorder_by (( '-amount''-amount' )
)

翻译自: https://www.pybloggers.com/2011/12/django-sphinx-sorting/

django 排序

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值