【发布时间】:2016-05-21 01:51:20
【问题描述】:
在 Django
context = Context({...}, autoescape=False)
result = template.render(context)
在 Django 1.8/1.9 中,我得到以下弃用警告:
RemovedInDjango110Warning: render() must be called with a dict, not a Context.
当然我可以将Context 实例更改为dict:
result = template.render({...})
但是我如何强制render 函数关闭自动转义而不在每个电子邮件模板中使用{% autoescape %} 标记(不是我项目中的每个模板!)?
我想到的只有一个解决方案:遍历所有上下文(字典)项并将它们标记为安全 (mark_safe),但这似乎并不优雅。
【问题讨论】:
标签: python django django-1.10