django-stored-messages 1.3.0

Django contrib.messages on steroids

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.

Features

  • 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)
  • Signalling api to perform actions in response to messages activity

Requirements

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

Documentation

The full documentation is at http://django-stored-messages.rtfd.org.

Quickstart

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

pip install django-stored-messages

Add it to the installed apps:

INSTALLED_APPS = (
    # ...
    'stored_messages',
)

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

MESSAGE_STORAGE = 'stored_messages.storage.PersistentStorage'

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
STORED_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
    do_something_with(unread_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:

STORED_MESSAGES = {
    'STORAGE_BACKEND': 'stored_messages.backends.RedisBackend',
    'REDIS_URL': 'redis://localhost:6379/0',
}

History

1.0.1 (2014-04-17)

  • Major bug fixed on inbox_get() backend api
  • Fixed InboxSerializer for redis backend messages
  • Enhanced testsuite
  • Added MessageDoesNotExist descriptions and return 404

1.0.0 (2014-04-01)

  • New backend architecture with Redis support
  • Support for broadcast messages

0.2.1 (2013-12-23)

  • Added stored_messages_count template tag and tests

0.2.0 (2013-10-22)

  • Added stored_messages_archive template tag
  • Extended REST api

0.1.2 (2013-10-13)

  • Added specific template tags for stored messages

0.1.1 (2013-10-10)

0.1.0 (2013-10-08)

  • First release on PyPI.
BSD

Author

evonove

Pip

django-stored-messages==1.3.0

Classifiers

  • Development Status :: 5 - Production/Stable
  • Framework :: Django
  • Intended Audience :: Developers
  • Programming Language :: Python :: 2
  • Programming Language :: Python :: 2.6
  • Programming Language :: Python :: 2.7
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.3
  • Programming Language :: Python :: 3.4
  • Natural Language :: English
  • License :: OSI Approved :: BSD License
  • Framework :: Django :: 1.6
  • Framework :: Django :: 1.7
  • Framework :: Django :: 1.8
  • Framework :: Django :: 1.4
  • Framework :: Django :: 1.5
File Type Python Version Uploaded On Downloads
django-stored-messages-1.3.0.tar.gz Source July 17, 2015 1,644
Version Release Date
1.3.0 July 17, 2015
1.2.0 July 9, 2015
1.1.0 Feb. 6, 2015
1.0.2 Sept. 5, 2014
1.0.1 April 17, 2014
1.0.0 April 3, 2014
0.2.1 Dec. 23, 2013
0.2.0 Oct. 22, 2013
0.1.2 Oct. 13, 2013
0.1.1 Oct. 10, 2013
0.1.0 Oct. 8, 2013
Date Package Version Action
Aug. 26, 2015, 12:27 a.m. django-stored-messages 0.1.2 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 0.1.1 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 0.1.0 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 0.2.0 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 1.2.0 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 1.3.0 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 0.2.1 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 1.0.2 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 1.0.1 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 1.0.0 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages 1.1.0 Release Created
Aug. 26, 2015, 12:27 a.m. django-stored-messages Package Created