Django 分页评论..有没有现有的解决方案?

发布于 2024-07-25 02:43:42 字数 1901 浏览 8 评论 0原文

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

我需要的只是一个简单的分页 django 评论,对于我使用的基本博客应用程序(来自 Django 基本应用程序),使用 简单的 has_previous 和 has_next

我已经复制了 django.contrib.comments 并尝试修改代码,但没有成功。 该代码很难理解(django/contrib/comments/templatetags/comments.py),因为它由 Node 和 Parser 组成,

这是我用于博客应用程序的 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 :)

提前致谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烧了回忆取暖 2024-08-01 02:43:42

我认为 django-pagination 可能就是您正在寻找的。

http://code.google.com/p/django-pagination/ (可用截屏视频)

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

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

楠木可依 2024-08-01 02:43:42

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

https://docs.djangoproject.com/en/开发/主题/分页/

Django also has a built in Pagination system

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文