当有人评论他们的帖子时如何使用 django-notification 通知用户
我已经在 django 中开发了一段时间,并开发了一个简洁的网站,具有撰写博客、发布问题、共享内容等功能。但是,仍然缺少一件事,即为用户创建通知。
我想做的是在用户的个人资料中通知用户,每当有人评论他们的帖子时,或者如果他们正在关注某个特定帖子并且该帖子有更新,则通知用户该更新。我已经浏览了很多应用程序,但我仍然对如何做到这一点感到非常困惑。
在使用 django-notification 的情况下,我似乎有一个印象(这可能是错误的),我只能使用它通过电子邮件通知用户,即我无法在用户个人资料中显示这些通知,就像我们在 Facebook 上一样。
首先我想知道我是否错了,然后我真的需要一些适当的教程或指导来指导如何去做。我知道如何注册通知并通过适当的信号发送它,但没有关于如何在模板中显示这些通知的文档(如果可以的话)。
任何指导/教程/入门文档将不胜感激。
I have been developing in django for sometime now, and have developed a neat website having functionality such as writing blogs, posting questions, sharing content etc. However there is still one thing that is missing and i.e. creating notification for users.
What I want to do is to inform users in their profiles, whenever somebody comments on their posts, or if they are following a particular post and there is an update on it, then inform the user of that update. I have looked around many applications but I am still very confused about how to do it.
In case of using django-notification
I seem to have an impression(which can be wrong) that I can use this only to inform the user via email, i.e. I cannot show these notifications in the user profile, just like we have on facebook.
Firstly I would like to know if I am wrong, and then I really need some proper tutorial or guidance on how to go about doing it. I know how to register a notification and send it on proper signal but there is no documentation on how to show these notices in a template, if this can be done.
Any guidance/tutorial/getting started doc will be deeply appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的 django-notifications 仅设计用于电子邮件通知。
这是一个信号槽,您可以将其添加到 models.py 中并根据自己的需求进行调整:
现在对于模板来说,非常简单。
templates/notification/new_comment/short.txt
templates/notification/new_comment/notice.html
templates/notification/new_comment/full.txt
警告:这是我们生产代码的一个非常简化的、未经测试的改编。
注意:Django-1.7 已弃用 post_syncdb 信号
以下是更多信息:
Yes django-notifications is only designed for email notifications.
Here is a signal slot that you can add to your models.py and tweak to your own needs:
Now for templates, pretty easy.
templates/notification/new_comment/short.txt
templates/notification/new_comment/notice.html
templates/notification/new_comment/full.txt
Warning: it's a very simplified, untested adaptation of our production code.
Note : Django-1.7 deprecated the post_syncdb signal
Here are some more information: