我有一个用 hatstack 搜索的函数,我需要获取 haystack 在数组中获取的每个对象的注释,我有这个:
def search(request):
if 'q' in request.GET and request.GET['q']:
q = request.GET['q']
results = SearchQuerySet().auto_query(q)
things = []
for r in results:
things.append(r.object)
return render_to_response('resultados.html',
{'things': things, 'query': q}, context_instance=RequestContext(request))
我如何将每个对象的评论数量附加到结果中?
如果我添加注释,调试器会抛出我:SearchQuerySet has not 'annotate' attribute