models.py 文件源码

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

项目:wger-lycan-clan 作者: andela 项目源码 文件源码
def send_email(self, request):
        '''
        Sends an email after being successfully added to the database (for user
        submitted ingredients only)
        '''
        if self.user and self.user.email:
            translation.activate(self.user.userprofile.notification_language.short_name)
            url = request.build_absolute_uri(self.get_absolute_url())
            subject = _('Ingredient was successfully added to the general database')
            context = {
                'ingredient': self.name,
                'url': url,
                'site': Site.objects.get_current().domain
            }
            message = render_to_string('ingredient/email_new.tpl', context)
            mail.send_mail(subject,
                           message,
                           settings.WGER_SETTINGS['EMAIL_FROM'],
                           [self.user.email],
                           fail_silently=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号