Django haystack 的分页问题
我正在使用 django-haystack 和简单的引擎,搜索很好,但分页不起作用。这是我的搜索结果模板的代码,
{% if query %}
<br>
<div id="contenido_pagina">
{% for result in page.object_list %}
{% if result.object.get_model == '[Video] ' %}
{% if result.object.publicar %}
<div class="salida_search">
<a href="{{result.object.get_full_url}}">{{result.object.get_model}}{{result.object.nombre}}</a><br>
<div class="resumen_search">
{{result.object.sinopsis|safe|truncatewords:"30"}}
</div>
<div class="link_search">
<a href="{{result.object.get_full_url}}">{{result.object.anio}}</a>
</div>
</div>
{% endif %}
{% else %}
<div class="salida_search">
<a href="{{result.object.get_full_url}}">{{result.object.get_model}}{{result.object.titulo}}</a><br>
<div class="resumen_search">
{% if result.object.contenido %}
{{result.object.contenido|safe|truncatewords:"30"}}
{% else %}
{{result.object.sinopsis|safe|truncatewords:"30"}}
{% endif %}
</div>
<div class="link_search">
<a href="{{result.object.get_full_url}}">{{result.object.fecha|date:"d M Y"}}</a>
</div>
</div>
{% endif %}
{% empty %}
<div>La busqueda <span class="highlighted">{{query}}</span> no obtuvo ningun resultado</div>
{% endfor %}
{% if page.has_previous or page.has_next %}
<div>
{% if page.has_previous %}<a href="?q={{ query }}&page={{ page.previous_page_number }}">{% endif %}« Anterior{% if page.has_previous %}</a>{% endif %}
|
{% if page.has_next %}<a href="?q={{ query }}&page={{ page.next_page_number }}">{% endif %}Siguiente »{% if page.has_next %}</a>{% endif %}
</div>
{% endif %}
</div>
<br>
{% else %}
{# Show some example queries to run, maybe query syntax, something else? #}
{% endif %}
当我转到下一页时,我看到与第一页相同的对象。我做错了什么?
i'm using django-haystack with simple engine, the search is fine, but the pagination is not working. This is the code of my search results template
{% if query %}
<br>
<div id="contenido_pagina">
{% for result in page.object_list %}
{% if result.object.get_model == '[Video] ' %}
{% if result.object.publicar %}
<div class="salida_search">
<a href="{{result.object.get_full_url}}">{{result.object.get_model}}{{result.object.nombre}}</a><br>
<div class="resumen_search">
{{result.object.sinopsis|safe|truncatewords:"30"}}
</div>
<div class="link_search">
<a href="{{result.object.get_full_url}}">{{result.object.anio}}</a>
</div>
</div>
{% endif %}
{% else %}
<div class="salida_search">
<a href="{{result.object.get_full_url}}">{{result.object.get_model}}{{result.object.titulo}}</a><br>
<div class="resumen_search">
{% if result.object.contenido %}
{{result.object.contenido|safe|truncatewords:"30"}}
{% else %}
{{result.object.sinopsis|safe|truncatewords:"30"}}
{% endif %}
</div>
<div class="link_search">
<a href="{{result.object.get_full_url}}">{{result.object.fecha|date:"d M Y"}}</a>
</div>
</div>
{% endif %}
{% empty %}
<div>La busqueda <span class="highlighted">{{query}}</span> no obtuvo ningun resultado</div>
{% endfor %}
{% if page.has_previous or page.has_next %}
<div>
{% if page.has_previous %}<a href="?q={{ query }}&page={{ page.previous_page_number }}">{% endif %}« Anterior{% if page.has_previous %}</a>{% endif %}
|
{% if page.has_next %}<a href="?q={{ query }}&page={{ page.next_page_number }}">{% endif %}Siguiente »{% if page.has_next %}</a>{% endif %}
</div>
{% endif %}
</div>
<br>
{% else %}
{# Show some example queries to run, maybe query syntax, something else? #}
{% endif %}
when i go to the next page i see the same objects that first page. What i am doing wrong??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有这个问题。从调试代码看来,这是分页器和搜索查询集的问题。不幸的是,我没有更多的时间投入其中,最终转向了开发环境。
I had this issue as well. From debugging the code it looks like it's an issue with the paginator and the searchqueryset. Unfortunately i didn't have more time to devote to it and ended up moving on to whoosh for development environment.
刚刚遇到这个。似乎这是简单后端的已知限制。
https://github.com/toastdriven/django-haystack/issues/320
Just encountered this. Seems as though it's a known limitation of the simple backend.
https://github.com/toastdriven/django-haystack/issues/320