关于提交评论的 Django 通知

标签 django django-models django-signals django-comments

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

最佳答案

django.contrib.comments.signals.comment_was_posted 连接到 notification .models.send() 视情况而定。

关于关于提交评论的 Django 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3804248/

相关文章:

Python:如何加入运算符?

python - 错误 : object. __new__() 不带参数

python - Django 信号与 Python 线程

python - 尝试在我的测试中激活 Django 信号

Django开发服务器断管错误

python - 使用 anaconda 发行版进行 Web 开发可以吗?

django - 过滤 django DatetimeField__date 不起作用

python - django-allauth 接收器信号在注册时向用户添加组权限

Django 管理和列宽通过 list_display

python - Django block.super 不渲染父模板中设置的变量