【问题标题】:Django loading static url and path from templateDjango从模板加载静态url和路径
【发布时间】:2014-09-15 10:58:25
【问题描述】:

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

所以,基本上它需要加载 product-images/book1.jpg...我如何将 productinfo.link 与 product-images/..连接起来 下面的代码不起作用..

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

【问题讨论】:

    标签: python django


    【解决方案1】:

    你试过了吗

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

    你可能需要

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

    避免html转义

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-12
      • 2014-04-30
      • 2013-01-20
      • 2012-03-21
      • 1970-01-01
      • 2018-04-16
      • 2016-11-27
      相关资源
      最近更新 更多