【问题标题】:Pagination problem with Django haystackDjango haystack 的分页问题
【发布时间】:2011-02-07 00:35:49
【问题描述】:

我正在使用带有简单引擎的 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 %}

当我转到下一页时,我看到的对象与第一页相同。我做错了什么??

【问题讨论】:

    标签: python django django-templates django-haystack django-pagination


    【解决方案1】:

    我也有这个问题。从调试代码来看,这似乎是分页器和 searchqueryset 的问题。不幸的是,我没有更多的时间投入到它上面,最终转向了开发环境。

    【讨论】:

      【解决方案2】:

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

      https://github.com/toastdriven/django-haystack/issues/320

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-07-08
        • 1970-01-01
        • 2021-04-03
        • 2016-05-07
        • 2011-03-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多