Django 2.x email 模板渲染

以前是这样的:


from django.template.loader import get_template
from django.template import Context

htmly = get_template('email/contact.html')
d = Context({'contact': contact, 'attachments': attachments})

html = htmly.render(dt)

如果异常:TypeError: context must be a dict rather than Context. 现在变为:


from django.template.loader import get_template

htmly = get_template('email/contact.html')
d = {'contact': contact, 'attachments': attachments}

html = htmly.render(dt)

render方法传入对象从context变为dict

输入类似这样的地址 "name@something.com"
输入类似这样的地址"http://someaddress.com"
验证码 不区分大小写(看不清)