A Django package to use Gotify as an email backend and logging handler.
Project description
Django Gotify
Self-hosted push notifications and alerting for your Django projects.
django-gotify is a lightweight package that integrates your Django application with a Gotify server. It provides a custom Email Backend to send standard Django emails as push notifications, and a built-in Logging Handler to instantly alert your devices about server errors and warnings.
🚀 Features
- Email Backend Integration: Acts as a drop-in replacement for Django's default email backend. Send notifications using standard
send_mail()calls. - Smart Logging Handler: Automatically routes Django logs to Gotify. It intelligently maps Python log levels (DEBUG, ERROR, CRITICAL) to Gotify message priorities.
- Thread-Safe: Safely processes and sends multiple messages concurrently.
- Fail Silently Support: Respects Django's
fail_silentlyflag to prevent notification errors from crashing your application.
📦 Installation
Install via pip:
pip install django-gotify
(Note: You do not need to add this to INSTALLED_APPS since it only provides backend classes and handlers).
🛠 Configuration & Usage
Add your Gotify server credentials to your settings.py:
GOTIFY_URL = 'http://127.0.0.1:6543'
GOTIFY_TOKEN = 'your_app_token' # For logging
GOTIFY_CLIENT = 'your_client_token' # Optional
1. Using as an Email Backend
To route all outgoing Django emails to Gotify, update your email backend in settings.py:
EMAIL_BACKEND = 'django_gotify.email.GotifyEmailBackend'
Now, anytime you use Django's send_mail(), it will appear as a push notification:
from django.core.mail import send_mail
send_mail(
subject="New User Registration",
message="A new user just signed up on the platform.",
from_email=None,
recipient_list=[], # Not required for Gotify
)
2. Using as a Logging Handler
To get real-time alerts for server errors, add the Gotify handler to your LOGGING configuration in settings.py:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'gotify': {
'level': 'ERROR',
'class': 'django_gotify.log.GotifyLogHandler',
},
},
'loggers': {
'django': {
'handlers': ['gotify', 'console'],
'level': 'ERROR',
'propagate': True,
},
},
}
💡 How it helps
Instead of paying for third-party SMS services or cluttering your inbox with automated server emails, you can:
- Monitor Errors Instantly: Get a push notification on your phone the second an
HTTP 500error occurs in production. - Simplify Alerts: Trigger internal admin alerts (like "New Order Received") using Django's familiar
send_mailfunctions without actually setting up an SMTP server.
🤝 Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
📄 License
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_gotify-0.1.0.tar.gz.
File metadata
- Download URL: django_gotify-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ece19b77e03aafcf3e9f5fe712c60714c9bdc1b8a59599984b0aa4142503c455
|
|
| MD5 |
d6d7134e65c566090c885f4c3d31f2a5
|
|
| BLAKE2b-256 |
9eca77c81bb54f6b0bd5ff0aeb7bdfb6aa8fdb87c095c8339c47d5a3f32f0dd9
|
Provenance
The following attestation bundles were made for django_gotify-0.1.0.tar.gz:
Publisher:
publish.yml on swayll/django-gotify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_gotify-0.1.0.tar.gz -
Subject digest:
ece19b77e03aafcf3e9f5fe712c60714c9bdc1b8a59599984b0aa4142503c455 - Sigstore transparency entry: 1040217197
- Sigstore integration time:
-
Permalink:
swayll/django-gotify@a139c474cc0bf80507ed1a7412a1e55bc7ca7580 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/swayll
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a139c474cc0bf80507ed1a7412a1e55bc7ca7580 -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_gotify-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_gotify-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6acc5999494b0d7eaaebb37421428843db6f6ee88b451d1a3356450b96e53d74
|
|
| MD5 |
1478d50e712e025968298a19386ff4e3
|
|
| BLAKE2b-256 |
4ff281300bef5648ff0f62b9f2d5cbe97a432a79b43ee64423c949e6e0acd728
|
Provenance
The following attestation bundles were made for django_gotify-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on swayll/django-gotify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_gotify-0.1.0-py3-none-any.whl -
Subject digest:
6acc5999494b0d7eaaebb37421428843db6f6ee88b451d1a3356450b96e53d74 - Sigstore transparency entry: 1040217301
- Sigstore integration time:
-
Permalink:
swayll/django-gotify@a139c474cc0bf80507ed1a7412a1e55bc7ca7580 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/swayll
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a139c474cc0bf80507ed1a7412a1e55bc7ca7580 -
Trigger Event:
release
-
Statement type: