Skip to main content
https://travis-ci.org/evonove/django-stored-messages.png?branch=master https://coveralls.io/repos/evonove/django-stored-messages/badge.png Documentation Status https://badge.fury.io/py/django-stored-messages.png

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)

  • Signalling api to perform actions in response to messages activity

Compatibility table

  • Python 2.7, 3.4, 3.5

  • Django 1.8, 1.9

  • Django Rest Framework >= 3.3 (only if you want to use REST endpoints)

Do you use an earlier version of Django or Django Rest Framework? An old version of stored_messages is available even if it’s not supported anymore. Anyway, plan a migration to a newer version.

Documentation

The full documentation is at http://django-stored-messages.rtfd.org. It includes migration instructions if you’re migrating from an earlier version of stored_messages.

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'

As last step, don’t forget to run Django migrations:

$ python manage.py migrate

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',
}

Examples

GitHub-like notifications with Stored Messages and AngularJS

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)

  • Fixed setup.py

0.1.0 (2013-10-08)

  • First release on PyPI.

Metadata

Release files for django3-stored-messages 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django3-stored-messages 2.0.2
File Size Uploaded
django3-stored-messages-2.0.2.tar.gz 21.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django3-stored-messages 2.0.2
File Interpreter ABI Platform
django3_stored_messages-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 52.1 kB

Release files / django3-stored-messages-2.0.2.tar.gz

Download URL django3-stored-messages-2.0.2.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
551c16fe54d632129ecb549d0060261d96c95292674ec898c4cd72c63c552ff9
BLAKE2b-256 checksum
How to use checksums
71063022128a76e162a688bd9ba7b9ce32828e99c7b083badb5273b82db9fe5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / django3_stored_messages-2.0.2-py3-none-any.whl

Download URL django3_stored_messages-2.0.2-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed56fbbe176b24e7adf23875cc0d101ce6ecaa1c27f7eba43c757e2aa7209cc2
BLAKE2b-256 checksum
How to use checksums
19c71494251096fa3a23145032e54c45a9b39939a2e38de2b0c31042a0793ec0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page