1

我怎样才能插入这个:

<strong>{% trans "Error!" %}</strong> {% trans "blablabla." %}

而不是这里的“xxx”:

{% include "alert.html" with connotation="error" message="xxx" %}

请指教。

4

1 回答 1

0

据我所知,除非您在视图中创建完整的消息并将其作为模板上下文参数传递,否则您不能这样做。

我建议不要传递完整的消息,而是传递一些错误代码,并在此基础上显示适当的消息"alert.html"

所以你的 include 语句会变成这样:

{% include "alert.html" with connotation="error" error_code=err_code %}

在里面alert.html,您可以设置条件以显示适当的消息。

{% if error_code == "404" %}
  <strong>{% trans "Not Found!" %}</strong>
{% endif %}
于 2013-06-27T17:18:23.360 回答