Skip to main content

Flexible, admin-driven notifications for Django with Celery/Redis, relational recipients, and templating.

Project description

django-silque-notifications

Flexible, admin-driven notifications for Django with Celery/Redis, relational recipient resolution, and safe templating.

  • Admin-first UX: define notifications in Django admin
  • Channels: Email (E), SMS (S), WhatsApp (W)
  • Triggers: New/Update/Delete, Value Change, Before/After date
  • Recipients: direct email/number, document fields, and relational mappings
  • Celery + Redis: scalable task queue with retries
  • Safe expressions and Jinja-like templating

Quickstart

  1. Install
pip install django-silque-notifications
  1. Add to Django settings
INSTALLED_APPS = [
    # ...
    "silque_notifications",
]

# Redis + Celery
REDIS_URL = "redis://localhost:6379/0"
CELERY_BROKER_URL = REDIS_URL
CELERY_RESULT_BACKEND = REDIS_URL
CELERY_ACCEPT_CONTENT = ["application/json"]
CELERY_RESULT_SERIALIZER = "json"
CELERY_TASK_SERIALIZER = "json"
CELERY_TIMEZONE = TIME_ZONE
CELERY_TASK_TRACK_STARTED = True
CELERY_TASK_TIME_LIMIT = 30 * 60
CELERY_RESULT_EXPIRES = 3600

# Optional mappings for relational recipients
S_NOTIFICATION_RELATIONAL_EMAIL_RECIPIENTS = {
    "supplier.Supplier": ["email_address"],
    "employee.Employee": ["email_address"],
    # Try these in order
    "silque_user.User": [("employee.email_address", "supplier.email_address")],
}
S_NOTIFICATION_RELATIONAL_NUMBER_RECIPIENTS = {
    "supplier.Supplier": ["mobile_number"],
    "employee.Employee": ["mobile_number"],
}

Note on names:

  • Install name (pip): django-silque-notifications
  • Import/app name (Python/Django): silque_notifications

Python imports can’t contain hyphens, so use underscores when importing or adding to INSTALLED_APPS:

import silque_notifications

INSTALLED_APPS = [
    # ...
    "silque_notifications",
]
  1. Wire Celery (standard Django pattern)

Create celery.py in your Django project and load it in __init__.py. See src/silque_notifications/CELERY_MIGRATION.md for a reference.

  1. Migrate
python manage.py migrate
  1. Start Celery worker
celery -A <your_project> worker --loglevel=info
  1. Use in admin
  • Add Notification entries
  • Choose Channel, Trigger, and Recipients
  • Save and let Celery handle delivery

How it works

See src/silque_notifications/NOTIFICATIONS-FLOW-AND-BEHAVIOR.md for the full, detailed guide. Highlights:

  • Recipient resolution supports:
    • Direct: by email/number
    • Dotted paths: doc.customer.email, old_doc.customer.email
    • Relational tokens: silque.doc.customer.supplier.Supplier ~ New Supplier
  • Heuristics and per-model hints discover likely email/number fields
  • Safe condition evaluation and templating
  • Celery tasks perform delivery with retries

Example recipient mappings

S_NOTIFICATION_RELATIONAL_EMAIL_RECIPIENTS = {
    "supplier.Supplier": ["email_address"],
    "employee.Employee": ["email_address"],
    # Priority example (sequential)
    "silque_user.User": [("employee.email_address", "supplier.email_address")],
}
S_NOTIFICATION_RELATIONAL_NUMBER_RECIPIENTS = {
    "supplier.Supplier": ["mobile_number"],
    "employee.Employee": ["mobile_number"],
}

Troubleshooting

  • No number suggestions? Ensure the selected model has a number field or FK/O2O to a mapped model.
  • A mapped field doesn’t appear in the UI? Mapped subfields are tried at runtime when a relational token is chosen.
  • ExtendedUser mapping: if actual field is email, use "euser.ExtendedUser": ["email"].

Development

  • Repo uses src layout and includes templates/static via MANIFEST.in
  • Lint/type/test with Ruff, mypy, and pytest (config included)

License

AGPL-3.0-or-later. By using or modifying this project (including over a network), you agree to share source under the same license and preserve notices.

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_silque_notifications-0.1.1.tar.gz (70.5 kB view details)

Uploaded Source

Built Distribution

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

django_silque_notifications-0.1.1-py3-none-any.whl (65.1 kB view details)

Uploaded Python 3

File details

Details for the file django_silque_notifications-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django_silque_notifications-0.1.1.tar.gz
Algorithm Hash digest
SHA256 65658e2ab34b2de9508a6258e3765d5601e487cad45b20e631fdd33c13270131
MD5 c2d86333e865bff86bbcd1f40827dab9
BLAKE2b-256 48571e732491913396974d846f1f04dcd7fb4ed535f3b4b5df22ef1ec24ebaea

See more details on using hashes here.

File details

Details for the file django_silque_notifications-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_silque_notifications-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2173034945915f490b03cdd1f6e23ad897273baae5645a6baadf9bf0025ffb79
MD5 5844013b54516c947f0cc642bec0a30a
BLAKE2b-256 682deb5de8815f837de452c87a855edd5cf63886f8c3dd7e185b8320807479fb

See more details on using hashes here.

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