3

我正在使用 Django 的 contrib.comments 并想了解以下内容。

是否有任何实用程序或应用程序可以插入到应用程序中,当在项目上发布评论时向您发送通知?

我并没有真正使用过信号,所以请稍微描述一下。

这就是我想出的。

from django.contrib.comments.signals import comment_was_posted
from django.core.mail import send_mail

if "notification" in settings.INSTALLED_APPS:
    from notification import models as notification

def comment_notification(request):
    user = request.user
    message = "123"
    notification.send([user], "new comment", {'message': message,}) 

    comment_was_posted.connect(comment_notification)
4

3 回答 3

3

根据需要连接django.contrib.comments.signals.comment_was_posted到。notification.models.send()

于 2010-09-27T13:37:47.230 回答
2

您必须使用信号注册您的comment_notification功能。comment_was_posted

from django.contrib.comments.signals import comment_was_posted

if "notification" in settings.INSTALLED_APPS:
    from notification import models as notification

    def comment_notification(sender, comment, request):
        user = request.user
        message = "123"
        notification.send([user], "new comment", {'message': message,}) 

    comment_was_posted.connect(comment_notification)
于 2010-09-27T17:21:17.087 回答
0

我不知道一个应用程序(很肯定会有一些东西在那里),但推出自己的应用程序相当简单。您可以点击Comment模型的comment_was_posted信号来调用将向您发送电子邮件的函数。

于 2010-09-27T13:38:31.690 回答