【问题标题】:Django-haystack & solr : Increase the number of resultsDjango-haystack & solr : 增加结果数
【发布时间】:2020-09-26 12:48:30
【问题描述】:

我有这个功能:

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 个结果,有没有办法增加这个数字?

谢谢。

【问题讨论】:

    标签: django solr django-haystack


    【解决方案1】:

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

    # settings.py
    
    # …
    
    HAYSTACK_SEARCH_RESULTS_PER_PAGE = 50
    
    # …

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多