以下是观点:
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中的sq显示为:
[<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。可能是什么问题?