django-user-messages - Offline addon for django.contrib.messages
django-user-messages adds offline messaging support to Django’s messaging framework. It achieves this by allowing to save messages in the database. The user_messages.api.get_messages utility and the user_messages.context_processors.messages context processor transparently concatenate Django’s messages and our own messages in a single list, therefore existing code works without any changes and without causing database writes. django-user-messages’ functions have to be used explicitly. I consider this a feature, not a bug.
Installation
Install django-user-messages using pip into your virtualenv.
Add user_messages to INSTALLED_APPS and run migrate.
Add the user_messages.context_processors.messages message processor somewhere after the default messages processor. Django’s admin app checks for the presence of the latter so you cannot simply remove it (except if you want to silence the "admin.E404" system check).
Use user_messages.api as you would use django.contrib.messages except that you pass the user model or ID as first parameter, not the current request.
Usage
Pretty much the same as Django’s messaging framework:
from user_messages import api api.info(user, 'Hey there') api.warning(user, 'Stop this') api.error(user, 'Not nice!') # Passing the ID is also possible; the user instance does not # have to be instantiated at all: api.success(user.id, 'Yay!')
django-user-messages’ messages supports two additional features not available in Django’s messages framework:
Messages can be delivered more than once by passing deliver_once=False. These messages have to be acknowledged explicitly. django-user-messages does not contain any code to do this.
It is possible to attach additional data by passing a dictionary as meta:
api.debug(user, 'Oww', meta={ 'url': 'http://example.com', })
For convenience, our messages have the same tags and level_tag properties as Django’s messages. Meta properties are also accessible in templates:
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li class="{{ message.tags }}".>
{% if message.meta.url %}<a href="{{ message.meta.url }}">{% endif %}
{{ message }}
{% if message.meta.url %}</a>{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
django-user-messages’ messages are also evaluated lazily.
Metadata
Release files for django_user_messages 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_user_messages-1.1.0.tar.gz | 7.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_user_messages-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.1 kB
Release files / django_user_messages-1.1.0.tar.gz
| Download URL | django_user_messages-1.1.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99ef6f94c921e181455278dd5d8bea54638f08abb4b3978a9ea09b2eb4781afd
|
|
BLAKE2b-256 checksum How to use checksums |
f0555562fa32cdfc75e8d80e3d30b72c56e80e1356052bba3754a4ce6d50a93e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.2
|
Release files / django_user_messages-1.1.0-py3-none-any.whl
| Download URL | django_user_messages-1.1.0-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd502ea27acbe63561215db8f8232cb66ab7fdcad2d5299e4f8f3f7dd0e02370
|
|
BLAKE2b-256 checksum How to use checksums |
0416756c5ed22d3cb7dc6c77c78b3c1a701c8de0b0b4a63b5c5edbfa0daa3c92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.2
|
Security for django_user_messages 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.