Django从querys发邮件

2024-09-29 23:33:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用django send_mail方法。我遇到了两个问题,特别是将邮件地址从列表转换成csv,以供收件人使用。第二个问题是从通知模型获取用户电子邮件列表。在

我的模型

class notifications(models.Model):
    notID = models.AutoField(primary_key=True)
    notSubject = models.CharField(max_length=100)
    notBody = models.TextField()
    notDate =  models.DateField(auto_now_add=True)
    notRecepients =  models.ManyToManyField(UserProfile, related_name='recepients')
    notPoster = models.ForeignKey(UserProfile,related_name='notposter') 
    deleted = models.BooleanField()

    def __unicode__(self):
    return u'%s ' % ( self.notSubject)

class UserProfile(User):
    onames = models.CharField(max_length=30, blank=True)
    phoneNumber = models.CharField(max_length=15, blank=True)
    regNo = models.CharField(max_length=15)
        image = models.ImageField(max_length=100,upload_to='photos/%Y/%m/%d', blank=True, null=True, default='photos/2010/03/placeholder.jpg')
    course = models.CharField(max_length=30, blank=True, null=True)
    timezone = models.CharField(max_length=50, default='Africa/Nairobi')
    smsCom = models.BooleanField()
    mailCom = models.BooleanField()


class notifications_sms_mail(models.Model):
    notId = models.OneToOneField(notifications)
    sms = models.BooleanField()
    email = models.BooleanField()

我的观点

^{pr2}$

Tags: 模型true列表modelmodelsmaillengthnotifications

热门问题