Added peridoic email sender with Celery

This commit is contained in:
ayxan
2022-09-30 01:20:48 +04:00
parent 221c753690
commit ad04604b6c
8 changed files with 152 additions and 5 deletions

View File

@@ -0,0 +1,3 @@
from .celery import app as celery_app
__all__ = ("celery_app",)

15
src/config/celery.py Normal file
View File

@@ -0,0 +1,15 @@
import os
from celery import Celery
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.development")
app = Celery("django_celery")
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()
app.conf.beat_schedule = {
'send-emails': {
'task': 'send_emails',
'schedule': 86400,
},
}

View File

@@ -92,4 +92,7 @@ EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD")
EMAIL_HOST_USER = 'series.notification@gmail.com'
EMAIL_PORT = 465
EMAIL_USE_SSL = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
# CELERY_BROKER_URL = "redis://localhost:6379"
# CELERY_RESULT_BACKEND = "redis://localhost:6379"