我想在Django模板标签中连接一个字符串,例如:
{% extend shop/shop_name/base.html %}
这shop_name是我的变量,我想将其与其余路径连接起来。
shop_name
假设我有shop_name=example.com并且我想要结果扩展shop/example.com/base.html。
shop_name=example.com
shop/example.com/base.html
用于:
{% with "shop/"|add:shop_name|add:"/base.html" as template %} {% include template %} {% endwith %}