【问题标题】:How to get <img src="{% static "{{request_filename}}" %}" alt="My image"/> working如何让 <img src="{% static "{{request_filename}}" %}" alt="My image"/> 工作
【发布时间】:2013-03-28 18:10:31
【问题描述】:

所以我通过views.py 传递一个变量

return  render_to_response(html, {'file': file})

进入我的html

<img src="{% static "{{file}}" %}" alt="My image"/> working

但是该文件在我的 html 中没有响应。谁能帮帮我。

【问题讨论】:

  • 就像@GarethRees 所说,文件已经在模板标签范围内可用,所以不要使用括号也会发布您的实际错误。 (html代码)

标签: html django image


【解决方案1】:

代替

{% static "{{file}}" %}

随便写

{% static file %}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-10
    • 2020-10-29
    相关资源
    最近更新 更多