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
- Install
pip install django-silque-notifications
- 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",
]
- 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.
- Migrate
python manage.py migrate
- Start Celery worker
celery -A <your_project> worker --loglevel=info
- 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
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_silque_notifications-0.1.1.tar.gz.
File metadata
- Download URL: django_silque_notifications-0.1.1.tar.gz
- Upload date:
- Size: 70.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65658e2ab34b2de9508a6258e3765d5601e487cad45b20e631fdd33c13270131
|
|
| MD5 |
c2d86333e865bff86bbcd1f40827dab9
|
|
| BLAKE2b-256 |
48571e732491913396974d846f1f04dcd7fb4ed535f3b4b5df22ef1ec24ebaea
|
File details
Details for the file django_silque_notifications-0.1.1-py3-none-any.whl.
File metadata
- Download URL: django_silque_notifications-0.1.1-py3-none-any.whl
- Upload date:
- Size: 65.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2173034945915f490b03cdd1f6e23ad897273baae5645a6baadf9bf0025ffb79
|
|
| MD5 |
5844013b54516c947f0cc642bec0a30a
|
|
| BLAKE2b-256 |
682deb5de8815f837de452c87a855edd5cf63886f8c3dd7e185b8320807479fb
|