Declare and Auto-discover Tasks
masterDjango Dramatiq automatically discovers tasks located in tasks modules within your installed apps (e.g., customers.tasks).
To change the module names used for discovery, set DRAMATIQ_AUTODISCOVER_MODULES in your settings.
To prevent specific modules from being processed as tasks, use DRAMATIQ_IGNORED_MODULES with support for wildcards.
import dramatiq
from django.core.mail import send_mail
from .models import Customer
@dramatiq.actor
def email_customer(customer_id, subject, message):
customer = Customer.get(pk=customer_id)
send_mail(subject, message, "webmaster@example.com", [customer.email])