[英]Django loading static url and path from template
I need to link a href tag in Django template..The file is located in a static location under folder product-images..The actual filename is located in the db... 我需要在Django模板中链接href标签。文件位于文件夹product-images下的静态位置。实际文件名位于数据库中。
So,basically it need to load product-images/book1.jpg...How can I concatenate productinfo.link with product-images/..The below code is not working.. 因此,基本上,它需要加载product-images / book1.jpg ...如何将productinfo.link与product-images /连接起来。以下代码无法正常工作。
<a href="{% static "product-images/" {{productinfo.link}} %}">
Have you tried 你有没有尝试过
<a href="{% static "product-images/" %}{{productinfo.link}}">
You may need 你可能需要
<a href="{% static "product-images/" %}{{ productinfo.link|safe }}">
to avoid html escaping 避免html转义
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.