[英]Django haystack related name search
所以我有以下模型:
class Article(models.Model, PublicationMixin):
publication = models.ForeignKey('Publication', related_name="articles")
...
class Publication(models.Model, PublicationMixin):
is_visible = models.BooleanField(default=False)
is_approved = models.BooleanField(default=False)
....
在我的search_indexes.py
我有:
class PublicationIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
id = indexes.CharField(model_attr='id', null=True)
我正在尝试将一个过滤器应用到我的搜索searchform
并仅返回包含文章的出版物。
我如何使用干草堆和相关名称实现这一目标? 我正在使用弹性搜索作为后端。
您是否尝试过这样引用索引中的articles字段: http ://django-haystack.readthedocs.org/en/latest/searchindex_api.html#advanced-data-preparation,然后使用SearchQuerySetApi检索所需的值: http : //django-haystack.readthedocs.org/en/latest/searchqueryset_api.html
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.