Display messages from django.contrib.messages as notifications in the browser.
Project description
django-messages-display
Display messages from django.contrib.messages as notifications in the browser.
Setup
Install the package using pip
:
python -m pip install django-messages-display
Add it to the installed apps of your project:
INSTALLED_APPS = [
...
"django_messages_display",
...
]
How to use
-
Load the template tag in your template:
{% load django_messages_display %}
-
Use the
django_messages_display
tag where you want the notifications to appear:{% django_messages_display %}
A good place to add this is before the closing body tag
</body>
. -
Load the CSS for the styling to apply:
{% load static %} ... <head> ... <link rel="stylesheet" href="{% static 'django_messages_display/django_messages_display.css' %}"> </head>
Example
It is convenient to integrate django-messages-display in your base template:
<!-- base.html -->
{% load static %}
{% load django_messages_display %}
...
<head>
...
<link rel="stylesheet" href="{% static 'django_messages_display/django_messages_display.css' %}">
</head>
...
{% django_messages_display %}
</body>
...
Configuration
To include a close button for each message, add the following to your Django settings:
DJANGO_MESSAGES_DISPLAY_CLOSE_BUTTON = True
Accessibility
The notifications have the relevant attributes so that screen readers announce each one without interrupting the user's flow. Even though the notifications visually disappear after a certain amount of time, they remain in the document to be accessible by screen readers on demand.
The colors used for the notifications meet the WCAG 2.1 AA contrast levels.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_messages_display-0.5.0.tar.gz
.
File metadata
- Download URL: django_messages_display-0.5.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7021d7eeabe608f37996a04f51886de976e2c136268e3a2ed6aaf351b8858385 |
|
MD5 | 358ee3ba971c1ef99f64816ae0d76b3f |
|
BLAKE2b-256 | 4a96ee36768083595782990354c12d3c0625cfcd965c62461322dce7bf0cca02 |
File details
Details for the file django_messages_display-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: django_messages_display-0.5.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4198e62da5ce2c7f6aa09f5acf7d1fe656046f1bf0ef5a612c212a717bf81d3 |
|
MD5 | d8aeb6967a2bffa50f78d673d8988d88 |
|
BLAKE2b-256 | 7f61430788f864d4efa287aea9f11ba8e506ed48d4f1265c8c9fdaf7642b0097 |