Django从模板加载静态URL和路径

时间:2014-07-24 02:56:22

标签: python django

我需要在Django模板中链接一个href标签。该文件位于文件夹product-images下的静态位置。实际文件名位于db ...

所以,基本上它需要加载product-images / book1.jpg ...如何将productinfo.link与product-images / ..连接起来。以下代码无效..

<a href="{% static "product-images/" {{productinfo.link}} %}">

1 个答案:

答案 0 :(得分:0)

你试过吗

<a href="{% static "product-images/" %}{{productinfo.link}}">

您可能需要

<a href="{% static "product-images/" %}{{ productinfo.link|safe }}">

避免html转义

相关问题