1

Django contrib.comments の既存のページネーション ソリューションはありますか?

必要なのは、単純な has_previous と has_nextを使用して、使用した Basic Blog アプリケーション (Django Basic Apps から) 用の単純なページ付けされた Django コメントだけです。

django.contrib.comments をコピーしてコードを変更しようとしましたが、成功しませんでした。ノードとパーサーで構成されているため、コードを理解するのはかなり困難です (django/contrib/comments/templatetags/comments.py)。

ブログ アプリケーションに使用した comments.html テンプレートを次に示します。

{% load comments markup %}
{% get_comment_list for object as comment_list %}
    {% if comment_list %}
    <div class="comments g_7 left">
        <a name="comments"></a>
        <div class="subtitle">Comments</div>
        {% for comment in comment_list %}
            {% if comment.is_public %}
            <div class="comment g_6" id="c{{ comment.id }}">
                <div class="comment_name g_6">
                <div class="comment_count right">
                    <a name="c{{ comment.id }}" href="{{ comment.get_absolute_url }}" {% ifnotequal comment.person_name null %}title="Permalink to {{ comment.person_name }}'s comment"{% endifnotequal %} class="comment_count">{{ forloop.counter }}</a></div>
                    Wrote by <strong>{% if comment.user_url %}<a href="{{ comment.user_url }}">{{ comment.user_name }}</a>{% else %}{{ comment.user_name }}{% endif %}</strong> on {{ comment.submit_date|date:"F j, Y" }} - {{ comment.submit_date|date:"P" }} 
                </div>
                <div class="comment_body g_6">{{ comment.comment|urlizetrunc:"60"|safe }}</div>
            </div>
            {% endif %}
        {% endfor %}

        <div class="clear"></div>
    </div>
    {% else %}
        No comments yet.
    {% endif %}

問題はget_comment_listテンプレートタグにあると思います:)

前もって感謝します

4

2 に答える 2

3

django-paginationはあなたが探しているものかもしれないと思います。

http://code.google.com/p/django-pagination/(スクリーンキャストが利用可能)

于 2009-06-22T17:22:43.730 に答える
0

Django には組み込みのページネーション システムもあります。

https://docs.djangoproject.com/en/dev/topics/pagination/

于 2012-01-18T02:51:11.400 に答える