我正在使用django消息框架来显示一次性消息。一切都工作正常,除了它没有正确呈现。无法弄清楚问题。 Python代码:
@receiver(user_signed_up)
def on_user_signed_up(sender, request, user, **kwargs):
context={'request':request}
msg='You have completed the first step of <a href="%s">Getting started with MDN</a>' % wiki_url(context, 'MDN/Getting_started')
messages.success(request, msg)
jinja2代码:
<div class="one time message">
{% if messages %}
<ul>
<li>{{ _('messages') }}</li>
</ul>
{% endif %}
</div>
所需的输出:您已完成Getting started with MDN
的第一步 My output: You have completed the first step of <a href"replaced url">Getting started with MDN</a>
注意:wiki_url是一个将路径转换为url的实用程序。
答案 0 :(得分:0)
添加extra_tags =&#39; safe&#39;在django消息框架中将消息标记为安全。答案以&#34开头;另一种选择是...&#34;是一个为我工作的人 https://stackoverflow.com/a/10124845/4297741