所以这里是视图:
def search(request, template_name='search/search.html'):
filters = {}
status = None
query = request.GET.get('q')
form = FilterForm(request.GET or None)
sqs = SearchQuerySet().models(Tutor).order_by('-overall_rating')
paginator = Paginator(sqs, 10)
page = request.GET.get('page')
try:
results = paginator.page(page)
except PageNotAnInteger:
results = paginator.page(1)
except EmptyPage:
results = paginator.page(paginator.num_pages)
context = {
'results': results,
'form': form,
}
return render(request, template_name, context)
现在ipdb中的sqs显示为:
[<SearchResult: tutoring.tutor (pk=u'2')>, <SearchResult: tutoring.tutor (pk=u'1')>]
它的计数是2。但是分页结果显示为:
paginator = Paginator(sqs, 10)
results = paginator.page(1)
results.object_list
[<SearchResult: tutoring.tutor (pk=u'2')>, None]
其中第二个结果实例更改为无。我在 django 1.4.1 和来自 github 的最新 haystack 上。可能是什么问题呢?