如何在 haystack 中默认签入特定模型?
我正在使用 haystack 进行搜索。默认情况下,它会搜索所有模型,然后提供已索引的模型清单以优化搜索。有没有一种方法可以覆盖此功能,即我可以使其默认在特定模型中搜索吗?任何帮助表示赞赏。
i am using haystack for searching. By default it searches in all the models and then provides the checklist of models indexed to refine search. Is there a way i can override this functionality i.e can i make it search in a particular model by default?? Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 SearchQuerySet 中的 models 方法:
http://docs.haystacksearch.org/dev /searchqueryset_api.html#models
或使用保留字段名称 django_ct,如下所示:
You can either use the models method from SearchQuerySet:
http://docs.haystacksearch.org/dev/searchqueryset_api.html#models
or use the reserved field name django_ct like this:
您可以覆盖 ModelSearchForm 来执行此操作,尝试类似的操作下面,将 app_label.model_name 替换为您默认要搜索的模型。
You can override ModelSearchForm to do this, try something like the below, replacing app_label.model_name with the model(s) you wish to search by default.