使用django-haystack对模板中的总搜索对象进行计数 [英] Count total search objects count in template using django-haystack
问题描述
FacetedSearchView
和 FacetedSearchForm
来进行搜索。我已经通过 searchqueryset
到我的 urls.py
FacetSearchView >文件。 但问题是我无法访问模板中的 searchqueryset
。我想做的是计算 searchqueryset
中找到的对象数。在shell中我可以使用S earchQuerySet()。filter(content =foo)。count()
,我怎么能在模板中这样做?请指导。我想要匹配搜索的对象总数。
干草堆使用标准的django分页: https://docs.djangoproject.com/en/dev/topics/pagination/
显示 {{page.object_list | length}}
{{page.paginator.count}}
页面上的结果 {{page.number}}
{{page.paginator.num_pages}}
I am using django haystack with xapian as the backend search engine. I am using FacetedSearchView
and FacetedSearchForm
for faceting over the search. I have passed searchqueryset
to the FacetSearchView
in my urls.py
file.
But the problem is I cannot access that searchqueryset
in template. All I want to do is count the number of objects in searchqueryset
found.
In shell I could achieve it using SearchQuerySet().filter(content="foo").count()
, how can I do that similarly in the template? Please guide. I want the total number of objects matching the search.
Haystack uses the standard django pagination: https://docs.djangoproject.com/en/dev/topics/pagination/
Showing {{ page.object_list|length }}
of {{ page.paginator.count }}
Results on Page {{ page.number }}
of {{ page.paginator.num_pages }}
这篇关于使用django-haystack对模板中的总搜索对象进行计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!