开发者

Django autoescaping, ignoring autoescape off and |safe

开发者 https://www.devze.com 2023-03-12 09:11 出处:网络
I\'ve got a Django filter that\'s not doing the right thing.I\'m expecting to see actual html in the output, but what I see are html escaped brackets.I\'ve tried autoescape off, and I\'ve tried |safe,

I've got a Django filter that's not doing the right thing. I'm expecting to see actual html in the output, but what I see are html escaped brackets. I've tried autoescape off, and I've tried |safe, and I've tried both at the same time. No joy. Wtf?

<td>{% autoescape off %}{{ notif.output|safe|insert_break开发者_开发问答s|linkify }}{% endautoescape %}</td>

I'm not seeing any errors, just autoescaped text that really shouldn't be escaped.


the answer to this is:

Make sure your template_dir in settings.py is pointing to the correct instance, when running multiple versions of your code on one host.


Ah, I just read the docs again. The answer is that having any filters after your safe makes the string unsafe again. So either put safe at the end, or put it at the end again.

0

精彩评论

暂无评论...
验证码 换一张
取 消