django - 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 个结果,有没有办法增加这个数字?
谢谢。
解决方案
这由HAYSTACK_SEARCH_RESULTS_PER_PAGE
设置 [readthedocs.io]指定。您可以在文件中指定不同的数字settings.py
:
# settings.py
# …
HAYSTACK_SEARCH_RESULTS_PER_PAGE = 50
# …
推荐阅读
- pine-script - 不会使绘图缩小的功能
- rest - 如何将多部分/表单数据请求发布到也具有 SOAP 端点的 WCF 服务中的 REST 端点
- html - Tailwind - 绝对与相对位置下拉菜单
- cmake - cmake 忽略 CMakeLists.txt 中的 CMAKE_INSTALL_PREFIX
- bash - 具有特定名称范围的 Bash 列表文件
- python - 我的“python”命令和“which python”指向不同的python版本
- php - 在数组内的字符串中保留换行符
- twitter - Twitter Card Images 在 Gatsby 应用程序上不起作用
- javascript - 在 d3js 中使用 join 方法时出现无效的合并错误
- flutter - 为什么 textbutton 不符合 ROW 中的普通文本