django-delayed-notifications provides tracking of notifications, and delayed sending.
Project description
Notifications
This application sends notifications to the user and emails addresses. It stores messages into a database, and sends can be delayed through a cron task.
Installation
$ pip install django-delayed-notifications
Add django_notifications
to your INSTALLED_APPS
:
INSTALLED_APPS = (
...
"django_notifications",
...
)
Apply the migrations:
$ ./manage.py migrate
Usage
Instead of sending a raw email, with the send_mail
django function, you can create a Notification object and program the sending.
Notification creation
from django_notifications.models import Notification
from django.utils.timezone import now
from datetime import timedelta
my_instance = "<A random object in the application>"
notification = Notification.objects.create(
subject="My beautiful email",
text_body="My text body",
html_body="""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="x-apple-disable-message-reformatting">
<title>My beautiful email</title>
</head>
<body>My HTML bod</body>
</html>
""",
from_email = "foo@example.org", # Optional
)
# It is possible to attach an object to the email (Optional)
notification.related_object = my_instance
# When using FSM, you can provide the states from / to (Optional)
notification.state_from = "active"
notification.state_to = "processing"
# Recipients management
# You can provide users
notification.recipients.set("<User instance>", "<User instance>",...)
# And / Or provides email address, `\n` separated
notification.email_recipients = "\n".join([
"foo@example.org", "bar@example.org"
])
# You can set the delayed sending date
notification.delayed_sending_at = now() + timedelta(days=1)
# Or you can send the email immediatly
notification.send()
Management command
The application provides a management command to send the emails:
$ ./manage.py send_notifications
12 notifications sent.
Admin
This application provides an admin interface for notifications.
Notes
The application is available in English and translated to French.
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
Hashes for django-delayed-notifications-0.6.12.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 929e0c7666ada6f46fd61506bed75558f5c98e1f73f603ed1d1c79b829c72b39 |
|
MD5 | 3803bb0c186f1e354079918033bd6d07 |
|
BLAKE2b-256 | 04462a7d5938f95a9299a82979fe47d6f2d19fde03cdca5498f4ae9e4b35d2b7 |
Hashes for django_delayed_notifications-0.6.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2ecdfe62392b7b9a230d60cefa0c9ab44336ebb9034324b16b58b6d3b1c1e6c |
|
MD5 | 67939330929d85a115e4f50759f6135b |
|
BLAKE2b-256 | f37ef57d10fc9812ae39a9a76eb8335c2c86c5dc696049d9428d92a57ff15029 |