Search code examples
pythondjangocode-reusepinax

reusable application for django site wide announcements that displays a message only once per user


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.


Solution

  • 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.

    edit

    Response to the comment

    from the docs:

    notification.send([to_user], "friends_invite", {"from_user": from_user})
    

    so this should work:

    notification.send(Users.objects.all(), "friends_invite", {"from_user": from_user})
    

    and if a queryset isnt right:

    notification.send([u for u in Users.objects.all()], "friends_invite", {"from_user": from_user})