Skip to main content

A Django package to use Gotify as an email backend and logging handler.

Project description

Django Gotify

Django CI PyPI version Python Versions License

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_silently flag 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 500 error occurs in production.
  • Simplify Alerts: Trigger internal admin alerts (like "New Order Received") using Django's familiar send_mail functions 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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_gotify-0.3.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_gotify-0.3.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file django_gotify-0.3.1.tar.gz.

File metadata

  • Download URL: django_gotify-0.3.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_gotify-0.3.1.tar.gz
Algorithm Hash digest
SHA256 a5f0faa47b2d6f8f1f1ec1e2d69b8b0f482fd5930e4dba61694abde995d444b6
MD5 57de23d63ac60d9ef749490f11dc3df0
BLAKE2b-256 97a54e2342a27ec2fbb3b82eaa42cdeeb03e4791ab2a01f77a0f7308dbbbd9e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_gotify-0.3.1.tar.gz:

Publisher: publish.yml on swayll/django-gotify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_gotify-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: django_gotify-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_gotify-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 232b5889ede1f611cd548cc24182be249958d405e0fb454e75515389df40440d
MD5 4b5200ebd28552d2cc7de2ec20f095dc
BLAKE2b-256 0c7b43aee331412d0ff3ea0a2aa3435ef61d20e4ef5d6c9074076157a1445632

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_gotify-0.3.1-py3-none-any.whl:

Publisher: publish.yml on swayll/django-gotify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page