Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Store Django messages on your project's backend
Python HTML
branch: master

Merge pull request #12 from avimeir/patch-1

Document marking message as read via REST API
latest commit a2a1542e16
@synasius synasius authored


Django Stored Messages

Django contrib.messages on steroids

The app integrates smoothly with Django's messages framework (django.contrib.messages), but users can decide which messages have to be stored on the database backend and kept available over sessions.


  • Seamless integration with django.contrib.messages
  • All the features are in a mixin you can attach to your existing storage
  • Stored messages are archived in the database or in a Redis instance
  • Users can configure which message levels have to be persisted
  • REST api to retrieve and mark messages as read (needs djangorestframework v2 or v3 being installed)


  • Django 1.4/1.5/1.6/1.7
  • Python 2.7/3.4
  • DRF 2/3 (only if you want to use REST endpoints)


The full documentation is at


Follow instruction for firing up django.contrib.messages, then install the app:

pip install django-stored-messages

Add it to the installed apps:

    # ...

In the settings, tell Django which is the message storage:


Then use it in a project through the django.contrib.messages api. The app provides for convenience some message levels which are persisted by default:

import stored_messages
from django.contrib import messages

# standard message
messages.add_message(request, messages.INFO, 'Hello world.')
# this will be persisted and marked as 'unread'
messages.add_message(request, stored_messages.STORED_INFO, 'Hello world, to the database!')

stored_messages expose the same api as well, so one can do:

import stored_messages
stored_messages.add_message(request, stored_messages.INFO, 'Hello!')

If you want to use standard message levels but persist the messages, just add something like this to the settings:

from django.contrib import messages
    # persist standard infos and standard errors
    'STORE_LEVELS': (messages.INFO, messages.ERROR,),

Iterating the messages will automatically mark them as read (but still persisted):

storage = messages.get_messages(request)
for unread_message in storage:
    # unread_message could be a stored message or a "standard" Django message

...unless you mark the storage as not used:

storage.used = False

You can mark a stored message as read at any time:

stored_messages.mark_read(request.user, message)

Want to store your messages on Redis instead of your database? Here you go:

    'STORAGE_BACKEND': 'stored_messages.backends.RedisBackend',
    'REDIS_URL': 'redis://localhost:6379/0',


GitHub-like notifications with Stored Messages and AngularJS

Something went wrong with that request. Please try again.