Dam*_*ard 1 django django-templates django-staticfiles
我有一个包含图像的网页。我希望使用 ? 缓存该图像 技术。但是,staticfiles 将问号编码为“%3F”,因此路径不再正确。
{% load staticfiles %}
<img src="{% static 'poll/img/test.jpg?v2' %}">
Run Code Online (Sandbox Code Playgroud)
被编译为.
<img src="/static/poll/img/test.jpg%3Fv2">
Run Code Online (Sandbox Code Playgroud)
没有test.jpg%3Fv2文件。所以它不显示。使用static它效果很好。
{% load static %}
<img src="{% static 'poll/img/test.jpg?v2' %}">
Run Code Online (Sandbox Code Playgroud)
Get 已按预期编译。我想使用staticfiles而不是像static我从云服务提供静态文件一样。有没有办法阻止我的字符串路径的编码或问题的解决方法?
要解决编码问题,请编写您自己的静态标记版本,或者只是将参数移至标记之外。
{% load staticfiles %}
<img src="{% static 'poll/img/test.jpg' %}?v2">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1425 次 |
| 最近记录: |