Admin announcements for Django (with optional django-unfold integration)
Project description
django-admin-announcements
Admin announcements for Django, with optional django-unfold layout integration.
Status: Testing. Alpha Release.
Features
- Displays a list of active announcements above the Django admin header as a banner.
- Allows admins to create announcements in the standard Django admin for editors (
is_staff) - Announcements can be assigned to groups and are time- and date-sensitive
- Allows editors to dismiss active announcements (stored in localStorage under
djangoAdminAnnouncements) - Supports optional Markdown content if installed with
markdownsupport (only for rendered HTML, no special fields) - Supports django-unfold using an optional
contrib.unfoldapp - Supports django-unfold-modal to display announcements in a modal instead of a full page
- Customize implementation via template tag
admin_announcements_banner - Supports installed admin themes, custom colors, and dark mode.
Requirements
- Python 3.10+
- Django 5.0+
- (Optional) django-unfold 0.52.0+ for the
contrib.unfoldintegration
Markdown support
- If installed with
markdownsupport, announcements can contain Markdown and will be rendered as HTML. - nh3 is used to sanitize HTML and prevent XSS.
- concrete.css (3kb) is used for Markdown styling.
Screenshots
| Django admin | Django admin detail |
|---|---|
| Unfold admin | Unfold admin detail |
|---|---|
Installation
pip install django-admin-announcements
Install with Markdown rendering support:
pip install "django-admin-announcements[markdown]"
Install with Markdown, Unfold, and Unfold Modal support:
pip install "django-admin-announcements[markdown,unfold,unfold-modal]"
Add to INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"admin_announcements",
"django.contrib.admin",
# ...
]
For Unfold integration, also add the contrib app:
INSTALLED_APPS = [
"admin_announcements.contrib.unfold",
"unfold",
"unfold_modal", # Optional: enables modal announcement detail links.
"admin_announcements",
"django.contrib.admin",
# ...
]
Keep admin_announcements.contrib.unfold before unfold so its Unfold-aware
admin template override is discovered first.
To open announcement detail links in an Unfold modal, also install the
unfold-modal extra and load django-unfold-modal assets in your Unfold
settings:
uv sync --extra unfold --extra unfold-modal --group test --group dev
from unfold_modal.utils import get_modal_scripts, get_modal_styles
UNFOLD = {
# ...
"STYLES": [*get_modal_styles()],
"SCRIPTS": [*get_modal_scripts()],
}
Without django-unfold-modal scripts, the links fall back to normal detail pages.
Custom template integration
If your project already overrides the default Django admin or Unfold templates, add the announcement assets and template tag to your custom template.
For the stock Django admin, extend your custom admin/base_site.html like this:
{% extends "admin/base_site.html" %}
{% load admin_announcements static %}
{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'admin_announcements/css/announcements.css' %}">
{% endblock %}
{% block extrahead %}
{{ block.super }}
<script src="{% static 'admin_announcements/js/announcements.js' %}"></script>
{% endblock %}
{% block header %}
{% admin_announcements_banner %}
{{ block.super }}
{% endblock %}
For Unfold, load the assets through UNFOLD settings instead of template
blocks. If you are not using django-unfold-modal, omit the modal imports and
the *get_modal_*() entries.
from django.templatetags.static import static
from unfold_modal.utils import get_modal_scripts, get_modal_styles
UNFOLD = {
# ...
"STYLES": [
lambda request: static("admin_announcements/css/announcements.css"),
*get_modal_styles(),
],
"SCRIPTS": [
lambda request: static("admin_announcements/js/announcements.js"),
*get_modal_scripts(),
],
}
Then render the banner inside a .unfold container so it inherits Unfold layout
spacing and color variables:
{% extends "admin/base.html" %}
{% load admin_announcements %}
{% block content %}
{% if not is_popup %}
<div class="unfold">
{% admin_announcements_banner %}
</div>
{% endif %}
{{ block.super }}
{% endblock %}
Run migrations:
python manage.py migrate admin_announcements
Local Development
Install dependencies:
uv sync --group test --group dev
npm ci
Install pre-commit hooks:
uv run pre-commit install
Run all pre-commit hooks manually:
uv run pre-commit run --all-files
Run the stock Django test server:
uv run tests/server/manage.py runserver 8080
Run the Unfold test server:
uv run --extra unfold tests/server/manage.py runserver 8080 --settings=testapp.settings_unfold
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_admin_announcements-0.1.0b0.tar.gz.
File metadata
- Download URL: django_admin_announcements-0.1.0b0.tar.gz
- Upload date:
- Size: 1.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25c5af9d30c14dbeb5fff08e99388e2477f171609c75d023b89dcee8e8aae7ef
|
|
| MD5 |
b3f865b71a943f1246ddb3f583262f7e
|
|
| BLAKE2b-256 |
a8e1179d9973313326dd4a58b437778fc280912e8cec4563b78cc38957110182
|
File details
Details for the file django_admin_announcements-0.1.0b0-py3-none-any.whl.
File metadata
- Download URL: django_admin_announcements-0.1.0b0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ffab6c071613f729d9ba6f3f3ccc01610c354815c33f45b54d2bdc7bc757a46
|
|
| MD5 |
efefc8392ce068eefbf720cef29160c4
|
|
| BLAKE2b-256 |
eb2281aabdcd33daac0460654232e1dace0cb092447da3970008f4300195f658
|