Django Paginated Comments .. is there any existing solutions?

◇◆丶佛笑我妖孽 提交于 2019-12-08 06:46:27

问题


is there any existing pagination solution for Django contrib.comments?

What I need is just a simple paginated django comments, for the Basic Blog application (from the Django Basic Apps) I used, using a simple has_previous and has_next

I have copied the django.contrib.comments and tried modify the code but with no success. The code is pretty hard to understand (django/contrib/comments/templatetags/comments.py) because it consists of Node and Parser

here is my comments.html template I used for the Blog application:

{% 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 %}

I think the problem lies in the get_comment_list templatetags :)

Thanks in advance


回答1:


I think django-pagination might be what you're looking for.

http://code.google.com/p/django-pagination/ (screencast available)




回答2:


Django also has a built in Pagination system

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



来源:https://stackoverflow.com/questions/1028229/django-paginated-comments-is-there-any-existing-solutions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!