Django Email Automation
Project description
Django email automation with cron.
Tested with :
django==3.1.1
Setup
Install with pip :
pip install django_solar
Add django_solar to django apps installed :
INSTALLED_APPS = [ ... 'django_solar', ]
Set Django email backend :
# Take a look at https://github.com/anymail/django-anymail ANYMAIL = { "MAILJET_API_KEY": env.str('MAILJET_API_KEY'), "MAILJET_SECRET_KEY": env.str('MAILJET_SECRET_KEY'), } MAILJET_API_KEY = env.str('MAILJET_API_KEY') MAILJET_SECRET_KEY = env.str('MAILJET_SECRET_KEY') EMAIL_BACKEND = "anymail.backends.mailjet.EmailBackend" DEFAULT_FROM_EMAIL = "hello@snoweb.fr" SERVER_EMAIL = "hello@snoweb.fr"
Set django_solar context :
DS_CRON_HOUR = 1 # Period of cron in hours DS_EVENT_MANAGER = "tests.manager.EventManager" # Class manager of events
Set cron command
0 * * * * python manage.py solar
Defines Events
Example of EventManger :
from django_solar import AEventManager, MailTemplate from django_solar.models import Mail from datetime import datetime class EventManager(AEventManager): def event_something(self): Mail.objects.create( mail='test@exemple.com', # Receiver send_at=datetime.now(), # Datetime send html=MailTemplate.get(key='test'), # HTML of email subject="Test Django Solar" # Subject of email )
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_solar-0.0.2.tar.gz
(17.3 kB
view details)
Built Distribution
File details
Details for the file django_solar-0.0.2.tar.gz
.
File metadata
- Download URL: django_solar-0.0.2.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7762e99b6dac7a0e89e8e2ba05842a4d61b61802ca363e581c10ade8bb03030 |
|
MD5 | 191895d78b5d24d76ac2714b06918cc5 |
|
BLAKE2b-256 | 99300ae1d8f1ef7d2f4d7ccefc90fe1a84bfb299b6163503773737396bc3ae64 |
Provenance
File details
Details for the file django_solar-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: django_solar-0.0.2-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 469a4710eed73c812b43b648b8a9e5c925cf641f8b31c0138d3ab491a549065a |
|
MD5 | e3b825ec33d81d733c7aceda2d7b2071 |
|
BLAKE2b-256 | 07e7fdf8039c6f55b44117f2951f44d2d6088c1327ca97a526e97d2e63480919 |