Django Haystack搜索Django Model PK [英] Django Haystack Search by Django Model PK
本文介绍了Django Haystack搜索Django Model PK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SearchQuerySet()。filter(pk = 12)
另一种选择是我将为模型pk的SearchIndex添加一个显式字段,但这似乎是浪费的,因为查询结果来自Haystack包含底层的django模型pk
解决方案
以下为我工作:
SearchQuerySet()。models(Product).filter(django_id ='10229')
Is there an easy hook for looking up Haystack results by Django model PK? Something like (this doesn't work)
SearchQuerySet().filter(pk=12)
The alternative is that I would add an explicit field to the SearchIndex for the model pk, but that seems wasteful, since the queryset results from Haystack contain the underlying django model pk
解决方案
Following worked for me:
SearchQuerySet().models(Product).filter(django_id='10229')
这篇关于Django Haystack搜索Django Model PK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文