Skip to main content
# Persistent Messages-like Framework for Django

Persistent, dismissible, targeted, messages framework for Django apps

## STATUS

Alpha - pls do not use. This README is six years old.

## Background

Django messages are great for one-off notifications to users, but not
for persistent notification banners. From the [official
documentation](https://docs.djangoproject.com/en/1.11/ref/contrib/messages/)
on the Django messages framework:

> Quite commonly in web applications, you need to display a one-time
> notification message to the user after processing a form or some other
> types of user input. [...] The messages framework allows you to
> temporarily store messages in one request and retrieve them for
> display in a subsequent request (usually the next one).

These one-time messages are usually dynamic, created within a view
function, to alert the user to something that has just happened. This
project is designed to extend the pattern to support configurable and
persistent messages to users. The canonical use case for this is the EU
Cookie warning. This appears to everyone (logged in or not) until the
user explicitly dismiss it. It is not related to any specific action
that the user has taken (beyond visiting the site for the first time),
and it persists across all requests.

## Compatibility

Python 3.12+ and Django 5.2-6.0

## Requirements

- Messages can be managed via the admin site
- The message can contain HTML (specifically href links)
- The message can be categorised (e.g. INFO | WARNING)
- The message can be targeted to appear to the following groups:
- All users (inc. anonymous)
- Authenticated users only
- Specific user groups only
- The message can be marked as dismissable
- The message can be enabled / disabled
- The message can expire (do not show after {{datetime}})
- Track message dismissals

## Use cases

- As the marketing team I would like to notify users of an event / activity
- As the tech team I would like to alert users to platform maintenance
- As the EU I would like to annoy people with a message about cookies

## Technical implementation

1. Print out all messages targeted at a user

```python
# live == enabled, not expired, not-dismissed, targeted at user
for m in PersistentMessage.objects.for_user(user).active():
print(m.message)
```

2. Display messages in a template using template context

```html
<body>
{% for m in persistent_messages %}
<div class="{{m.extra_tags}}">{{ m.message }}</div>
{% endfor %} ...
</body>
```

Metadata

Release files for django-persistent-messages 0.5

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

Source distribution (sdist)

Source distribution for django-persistent-messages 0.5
File Size Uploaded
django_persistent_messages-0.5.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-persistent-messages 0.5
File Interpreter ABI Platform
django_persistent_messages-0.5-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / django_persistent_messages-0.5.tar.gz

Download URL django_persistent_messages-0.5.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
186bb9af8ccf5d82e34d4897d0500ac99b542cb20ab32e719f1aa6627d5a9543
BLAKE2b-256 checksum
How to use checksums
e2288a8b6968046da31cd2d9af7099ecfa71037976561db153c7011dbee97f52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / django_persistent_messages-0.5-py3-none-any.whl

Download URL django_persistent_messages-0.5-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6788442629d702548d96b859f6398073a8ee6a55a91f1e3c749270c821f59e4c
BLAKE2b-256 checksum
How to use checksums
9efcc757627c121208106fc3fcf6b9f575431923ee5d6867a7a5d8e124ec33f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.5 This release

2 release files

0.4

2 release files

0.3

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