Count the number of shared search objects in a template using django-haystack

I am using haystack django with xapian as a backend search engine. I use FacetedSearchView and FacetedSearchForm to cut over the search. I passed the searchqueryset to FacetSearchView in my urls.py file.

But the problem is that I cannot access this searchqueryset template. All I want to do is count the number of objects found in searchqueryset .

In the shell, I could achieve this using S earchQuerySet().filter(content="foo").count() , how can I do this the same way in the template? Please guide. I want the total number of objects to match the search.

+8
python django xapian django-haystack
source share
3 answers

Haystack uses the standard django breakdown: https://docs.djangoproject.com/en/dev/topics/pagination/

Showing {{ page.object_list|length }} of {{ page.paginator.count }} Results on the page {{ page.number }} of {{ page.paginator.num_pages }}

+30
source share

If you want to show a range of results instead of a page number, for example. "Results 21-40 of 1001" . You can do

 Results {{ page.start_index }} - {{ page.end_index }} of {{ page.paginator.count }} 
+5
source share
 {{ page.object_list | length }} 
0
source share

All Articles