django-admin-notifications
A simple app to allow apps to register notifications that can be displayed in the admin via a template tag
Installation
Add ‘admin_notifications’ to INSTALLED_APPS
Basic usage
Customize whichever of your admin templates you which to display the notifications thus.
load the template tags at the start of the template:
{% load notification_tag %}
add the tag to your template. I customised the admin index template and placed the tag before the ‘content-main’ DIV like thus:
{% block content %}
<!-- here's the tag you add -->
{% error_notifications %}
<div id=''content-main">
in urls.py:
import admin_notifications admin_notifications.autodiscover()
This looks in each app for a file called ‘notifications.py and registers it if it exists.
Notifications files can contain as many functions as you like. Each one should return a string which can contain HTML and each one needs to be registered using admin_notifications.register
If you return an empty string then no notification is shown.
Notifications functions are called every time the admin template is rendered so avoid doing heavy calculations in the notification.
An example notifications.py might look like this:
import admin_notifications
from models import Url
def notification():
broken_links = Url.objects.filter(status=False).count()
if broken_links:
return "You have %s broken link%s.<br>You can view or fix them using the <a href='/admin/linkcheck/'>Link Manager</a>." % (broken_links, "s" if broken_links>1 else "")
else:
return ''
admin_notifications.register(notification)
Metadata
Release files for django-admin-notifications 0.6.3
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-admin-notifications-0.6.3.tar.gz | 3.3 kB | Without provenance | Details |
Release files / django-admin-notifications-0.6.3.tar.gz
| Download URL | django-admin-notifications-0.6.3.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8d255c221cc17a95071aabe99e582057858451b014ec807dba2b50419b051d2
|
|
BLAKE2b-256 checksum How to use checksums |
5908eb5b51a61ffb52da13c4ea6e3d52ef1d4ca80048bc7ce82f67fb7ab26787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-admin-notifications 0.6.3
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.