首页 > 解决方案 > 回复如何与 django_comments_xtd 中的评论相关联

问题描述

我正在查看 django_comments_xtd 的源代码。当用户通过点击“回复”回复现有评论时,

## /templates/django_comments_xtd/comment_tree.html
{% if item.comment.allow_thread and not item.comment.is_removed %}
    {% if allow_feedback %}&nbsp;&nbsp;<span class="text-muted">&bull;</span>&nbsp;&nbsp;{% endif %}<a class="small mutedlink" href="{{ item.comment.get_reply_url }}">{% trans "Reply" %}</a>
{% endif %}

用户将被带到http://example.com/comments/reply/(comment_pk)并由 处理views.rely

## django_comments_xtd/views.py
def reply(request, cid):
    ...
    return render(request, "django_comments_xtd/reply.html",
                  {"comment": comment, "form": form, "cid": cid, "next": next})

然后在django_comments_xtd/reply.html

## django_comments_xtd/reply.html
...
<div class="card-body">
    <h4 class="card-title text-center pb-3">{% trans "Post your comment" %}</h4>
    {% include "comments/form.html" %}
</div>
...

问:我真的没有看到将回复与现有评论相关联的实现,换句话说,回复的thread_id, parent_id,level被相应地赋予了值。我有没有忽略什么?

为什么我要挖掘这是因为我想对其进行一些自定义,以便单击回复不会将用户重定向到另一个 URL,而是在回复按钮下方打开评论对话框,然后用户输入评论并直接单击“发送” .

标签: django-comments

解决方案


推荐阅读