我正在使用 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)