可重用的django站点广泛的应用程序,每个用户只显示一次消息 [英] reusable application for django site wide announcements that displays a message only once per user
问题描述
我想在我的django应用程序中向注册用户显示一次消息。我发现 django-announcements ,这似乎在做我想要的 - 但是我在测试中发现通过使用会话变量将消息标记为已读,如果用户注销,消息将消失。这意味着如果用户在登录,注销,然后重新登录后关闭消息,则再次显示一条消息。
I want to show various messages to registered users only once in my django application. I found django-announcements which seemed to do what I want - but I found in testing it marks messages as read by using a session variable, which disappears if the user logs out. This means a message is shown again to a user if they dismiss it when logged in, log out, and then log in again.
我想知道是否有人知道应用程序
I wondered if anyone know of an application that I might be able to use here without re-inventing the wheel.
推荐答案
看看 django-notification 。它被pinax使用,似乎像你正在寻找的那样工作。至少它保存在数据库中的状态。
Have a look at django-notification. It is used by pinax, there it seems to work like what you are searching for. At least it saves the status in the db.
回复评论
从 docs :
notification.send([to_user], "friends_invite", {"from_user": from_user})
所以这应该工作:
notification.send(Users.objects.all(), "friends_invite", {"from_user": from_user})
如果查询器不正确:
notification.send([u for u in Users.objects.all()], "friends_invite", {"from_user": from_user})
这篇关于可重用的django站点广泛的应用程序,每个用户只显示一次消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!