Django haystack 的分页问题

发布于 2024-10-15 22:39:52 字数 2228 浏览 2 评论 0原文

我正在使用 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 }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Anterior{% if page.has_previous %}</a>{% endif %}
        |
        {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Siguiente &raquo;{% 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尛丟丟 2024-10-22 22:39:52

我也有这个问题。从调试代码看来,这是分页器和搜索查询集的问题。不幸的是,我没有更多的时间投入其中,最终转向了开发环境。

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.

豆芽 2024-10-22 22:39:52

刚刚遇到这个。似乎这是简单后端的已知限制。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文