This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, unicode_literals | |
# This will make sure the app is always imported when | |
# Django starts so that shared_task will use this app. | |
from .celery import app as celery_app | |
__all__ = ('celery_app',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, unicode_literals | |
import os | |
from celery import Celery | |
# set the default Django settings module for the 'celery' program. | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_twilio.settings') | |
app = Celery('django_twilio') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import task | |
from celery import shared_task | |
from sms_app.middleware import TwillioNotificationMiddleware | |
# We can have either registered task | |
@task(name='send-sms') | |
def send_sms_task(message,phone,dlivery_time,delivery_day): | |
TwillioNotificationMiddleware.process_sms(message,phone,dlivery_time,delivery_day) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery.schedules import crontab | |
CELERY_BROKER_URL = 'redis://localhost:6379' #You can also refrence a remote url from e.g heroku | |
CELERY_TIMEZONE = 'Europe/Warsaw' | |
HOUR = 0 | |
DAY = 0 | |
# Let's make things happen | |
CELERY_BEAT_SCHEDULE = { | |
'send-sms-every-hour': { | |
'task': 'send-sms', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import logging | |
import os | |
from django.conf import settings | |
from django.views import GenericView | |
from django.core.exceptions import ImproperlyConfigured | |
from dotenv import load_dotenv | |
from twilio.rest import Client |