我经历了很多博客和应用程序,大多数应用程序都使用Django auth用户集成通知功能,所以如果有任何方式或博客可以提供帮助。
我面临的问题是我将我的用户模型定义为:
class user_signup(models.Model):
full_name = models.CharField('Full Name',max_length=200)
user_email = models.EmailField('User Email', max_length=255)
user_password = models.CharField('Password', max_length=30)
date_time=models.DateTimeField(auto_now=True)
def __unicode__(self):
return smart_unicode(self.user_email)
我想在现有模型中添加通知中心,因此可能是最好的方式。
答案 0 :(得分:0)
不知道为什么有人没有回答
你可以使用我最近使用的一个,它的django-notification模块和下面的代码片段 的处理程序: - 强>
from django.db.models.signals import post_save
from notifications.signals import notify
from myapp.models import MyModel
def my_handler(sender, instance, created, **kwargs):
notify.send(instance, verb='was saved')
post_save.connect(my_handler, sender=MyModel)
生成通知
from notifications.signals import notify
notify.send(user, recipient=user, verb='you reached level 10')
// "recipient" can also be a Group, the notification will be sent to all the Users in the Group
notify.send(comment.user, recipient=group, verb=u'replied', action_object=comment,
description=comment.comment, target=comment.content_object)
notify.send(follow_instance.user, recipient=follow_instance.follow_object, verb=u'has followed you',
action_object=instance, description=u'', target=follow_instance.follow_object, level='success')
阅读参考: -