与Django干草堆的分页问题

时间:2011-02-07 00:35:50

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

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

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

2 个答案:

答案 0 :(得分:0)

我也有这个问题。通过调试代码,它看起来像是paginator和searchqueryset的问题。不幸的是,我没有更多时间投入其中,最终转向了开发环境。

答案 1 :(得分:0)

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

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