Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 请参阅用户回复评论的电子邮件_Python_Django_Django Email - Fatal编程技术网

Python 请参阅用户回复评论的电子邮件

Python 请参阅用户回复评论的电子邮件,python,django,django-email,Python,Django,Django Email,我们在are项目中使用,用于员工和客户之间的沟通。员工沟通工作是内部的,我制作了一个定制的电子邮件通知系统,每当其他人在你的页面上留言时,它都会通知你 现在我面临的问题是,想要回复评论的用户只会通知自己,而不会通知留下评论的工作人员 电子邮件通知设置由两部分组成,第一部分是为发表评论的工作人员设置的,第二部分是为回复评论的用户设置的 问题是如何引用已经准备好留下评论的用户,我需要他的电子邮件,这样我就可以将他添加到收件人列表中,以便在其他人回复评论时通知他 comment.user和commen

我们在are项目中使用,用于员工和客户之间的沟通。员工沟通工作是内部的,我制作了一个定制的电子邮件通知系统,每当其他人在你的页面上留言时,它都会通知你

现在我面临的问题是,想要回复评论的用户只会通知自己,而不会通知留下评论的工作人员

电子邮件通知设置由两部分组成,第一部分是为发表评论的工作人员设置的,第二部分是为回复评论的用户设置的

问题是如何引用已经准备好留下评论的用户,我需要他的电子邮件,这样我就可以将他添加到收件人列表中,以便在其他人回复评论时通知他

comment.user
comment.user\u email
是您在评论模型中引用的内容,但是我找不到如何引用
user\u email
当您想要回复时,谁已经准备好留下评论,这部分解释模型字段,我可以理解

user_email-发布评论的用户的电子邮件

第一部分很完美,但第二部分是指留下评论的用户,这就是为什么不会通知另一个用户的原因,所以请有人帮助我更好地了解如何引用我正在回复的
用户电子邮件,这样我才能使其正常工作

def send_comment_posted_emails(self, comment):
    comment_user = comment.user
    comment_user_email = comment.user_email
    comment_text = comment.comment
    handler_user = self.account_handler
    handler_email = handler_user.email

    # First part
    if handler_email is not None and handler_email != comment_user.email:
        current_site = Site.objects.get_current()
        sub_org_url = self.get_view_url() + "#CommentsDiv"
        ctx = {"sub_org_url": sub_org_url, "site_name": current_site.name, "sub_org_sn": self.serial_number,
               "posted_name": user_util.get_user_full_name_or_user_name(comment_user),
               "comment_text": comment_text}
        subject = render_to_string("clients/emails/email_sub_org_comment_posted_subject.txt", ctx)
        subject = "".join(subject.splitlines())
        message = render_to_string("clients/emails/email_sub_org_comment_posted_message.html", ctx)

        MailManager.send_mail_with_error_handler(subject, message, settings.DEFAULT_FROM_EMAIL,
                                                 [handler_email, comment_user_email], message_html=message)

    # Second part
    if handler_email is not None and handler_email == comment_user.email:
        current_site = Site.objects.get_current()
        sub_org_url = self.get_view_url() + "#CommentsDiv"
        ctx = {"sub_org_url": sub_org_url, "site_name": current_site.name, "sub_org_sn": self.serial_number,
               "posted_name": user_util.get_user_full_name_or_user_name(comment_user),
               "comment_text": comment_text}
        subject = render_to_string("clients/emails/reply_to_email_sub_org_comment_posted_subject.txt", ctx)
        subject = "".join(subject.splitlines())
        message = render_to_string("clients/emails/reply_to_email_sub_org_comment_posted_message.html", ctx)

        MailManager.send_mail_with_error_handler(subject, message, settings.DEFAULT_FROM_EMAIL,
                                                 [handler_email, comment_user_email], message_html=message)

我发现,
django contrib注释
现在由两个独立的库组成/划分

  • 因此,在
    threadedcomments
    中有一个模型字段,当您回复注释时,您可以在该字段上建立关联。因此,我刚刚制作了类似
    comment.parent.user\u email
    的内容,我检查了parent是否定义,而不是None,并解决了问题