【发布时间】:2019-05-05 15:07:45
【问题描述】:
我想改进我的django message:在文本中添加breakline,并使用django reverse url 添加网址。
这是我的消息:
messages.error(self.request, _( f"The link to download the document has expired. Please request it again in our catalogue : {redirect to freepub-home}"
我想通过在. 之后添加一个新行来分隔我的消息,以获得类似这样的内容:
messages.error(self.request, _( f"The link to download the document has expired.
Please request it again in our catalogue : {redirect to freepub-home}"
那么,由于反向 url 到 "freepub-home",我如何在我的消息中设置 django 重定向?
提前谢谢你!
编辑:
我克服设置断线:
messages.error(self.request, mark_safe(
"The link to download the document has expired."
"<br />"
"Please request it again in our catalogue :
<a href='{% url "freepub-home" %}'> my link </a>")
但到目前为止我还没有找到如何在里面传递 django url,因为我有引号和双引号的问题。
【问题讨论】: