我用簡單的引擎Django乾草堆,搜索很好,但分頁不起作用。這是我的搜索結果模板的代碼Django乾草堆的分頁問題
{% 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 %}
當我進入下一頁時,我看到與第一頁相同的對象。我做錯了什麼?
使用whoosh解決我的問題。 – eos87 2011-02-22 16:17:52