Я пытаюсь запланировать отправку электронной почты с помощью сигнала django

Получение ошибок в терминале qcluster

"django_q\cluster.py", строка 432, in worker res = f(*task["args"], **task["kwargs"]) TypeError: 'NoneType' object is not callable"

from django.db.models.signals import post_save
from django.dispatch import receiver
from django_q.tasks import schedule
from django_q.models import Schedule
from django.utils import timezone
from django.conf import settings
from django.core.mail import send_mail
from .models import Lead


@receiver(post_save, sender=Lead)
def schedule_lead_email(sender, instance, **kwargs):
    scheduled_time = timezone.now()  # Adjust the time delay as needed
    schedule(
        send_follow_up_email,
        instance.email,
        name=f'Send-lead{instance.name}',
        schedule_type='O',  # 'O' stands for 'Once'
        next_run=scheduled_time,
    )
    

def send_follow_up_email(email):
    # Send your email using the provided email address
    send_mail(
        'Subject',
        'Message',
        settings.EMAIL_HOST_USER,  # Use your sender email
        [email],
        fail_silently=False,
    )

Это код models.py.

from django.db import models

class Lead(models.Model):
    name = models.CharField(max_length=100)
    email = models.EmailField()
    phone_number = models.CharField(max_length=20)
    lead_purpose = models.TextField()
    created_at = models.DateTimeField(auto_now_add=True)


    def __str__(self):
        return self.name
Вернуться на верх