models.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:byro 作者: byro 项目源码 文件源码
def to_mail(self, email, locale=None, context=None, skip_queue=False):
        with override(locale):
            context = context or dict()
            try:
                subject = str(self.subject).format(**context)
                text = str(self.text).format(**context)
            except KeyError as e:
                raise SendMailException(f'Experienced KeyError when rendering Text: {str(e)}')

            mail = EMail(
                to=email,
                reply_to=self.reply_to,
                bcc=self.bcc,
                subject=subject,
                text=text,
            )
            if skip_queue:
                mail.send()
            else:
                mail.save()
        return mail
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号