exercises.py 文件源码

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

项目:wger-lycan-clan 作者: andela 项目源码 文件源码
def form_valid(self, form):
        '''
        If the form is valid send email notifications to the site administrators.

        We don't return the super().form_valid because we don't want the data
        to be saved.
        '''
        subject = 'Correction submitted for exercise #{0}'.format(self.get_object().pk)
        context = {
            'exercise': self.get_object(),
            'form_data': form.cleaned_data,
            'user': self.request.user
        }
        message = render_to_string('exercise/email_correction.tpl', context)
        mail.mail_admins(six.text_type(subject),
                         six.text_type(message),
                         fail_silently=True)

        messages.success(self.request, self.messages)
        return HttpResponseRedirect(reverse('exercise:exercise:view',
                                            kwargs={'id': self.object.id}))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号