首页 > 解决方案 > Django-haystack & solr : 增加结果数

问题描述

我有这个功能:

def search_books(request):
    search_text = request.POST.get('search_text')
    if search_text:
        books = SearchQuerySet().filter(content=search_text).filter(quantite__gte=0)

    else:
        books = []
    return render_to_response("search/search.html", {'books': books})

默认情况下它只返回 20 个结果,有没有办法增加这个数字?

谢谢。

标签: djangosolrdjango-haystack

解决方案


这由HAYSTACK_SEARCH_RESULTS_PER_PAGE设置 [readthedocs.io]指定。您可以在文件中指定不同的数字settings.py

# settings.py

# …

HAYSTACK_SEARCH_RESULTS_PER_PAGE = 50

# …

推荐阅读