【发布时间】:2018-03-01 12:38:33
【问题描述】:
{% if shelf.script or shelf.log_url %}
{% if shelf.log_url %}
Log URL: {{ shelf.log_url }}<br />
{% endif %}
{% if shelf.log_url %}
<b>Another URL:</b> {{ shelf.log_url.replace("/tmp/BOOTLOG/", "http://www.sxp.com") }}<br />
{% endif %}
{% endif %}
我已经有一个日志 URL,我想用域地址更新这个 URL,并在末尾添加 /index.html。
我想替换这个网址
shelf.log_url 输出 = /tmp/BOOTLOG/darwin_12345.tgz
到这样的事情。
www.sxp.com/darwin_12345/index.html
如何在 Django 模板中进行操作?
【问题讨论】:
-
为什么需要在模板中做这个?为什么不在视图中,或者在
shelf上定义一个方法? -
显然,视图中的逻辑。最可能的
标签: django python-2.7 django-templates