-->

Django的分页评论..有任何现有的解决方案?(Django Paginated Comments

2019-09-16 17:05发布

有Django的contrib.comments任何现有的分页解决方案吗?

我需要的只是一个简单的分页Django的意见,对于基本的博客应用(从Django的基本应用程序)我用,使用简单has_previous和has_next

我抄django.contrib.comments,并试图修改代码,但没有成功。 该代码是非常难以理解(Django的/的contrib /评论/ 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 templatetags :)

提前致谢

Answer 1:

我认为Django的分页可能是你在找什么。

http://code.google.com/p/django-pagination/ (截屏提供)



Answer 2:

Django的也有一个内置的分页系统

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



文章来源: Django Paginated Comments .. is there any existing solutions?