I'm using Solr with Haystack and I need to show a date facet in a Django Template, but I have no clue on how to use this result:
My sqs:
>>> sqs = SearchQuerySet().date_facet('date_inserted', start_date=datetime.date(2008,01,01), end_date=datetime.date(2012,01,01), gap_by='year')
>>> sqs.facet_counts()
The result is this:
{
'fields': {},
'dates': {
'date_inserted': {
'end': '2012-01-01T00:00:00Z',
'2009-01-01T00:00:00Z': 0,
'gap': '+1YEAR/YEAR',
'2008-01-01T00:00:00Z': 0,
'2011-01-01T00:00:00Z': 637,
'2010-01-01T00:00:00Z': 0
}
},
'queries': {}
}
How can I use this result in a Django Template? I need to facet by year, for example:
2011 (637)
2010 (0)
2009 (0)
2008 (0)
Any clue on how to achieve this on a Template?
documentation gives great example