我将图像路径保存在数据库中,例如“Image/upload/imageOne.jpg”并将图像文件夹保存在静态目录中,然后我想使用此标签在 html 中显示此图像:
<img src="{% static '{{ product.productImagePath }}' %}" alt="{{ product.productName }}" width="800px" height="300px">
但是我有错误并且找不到路径,只是显示 alt 如何修复它? 感谢您的帮助
最佳答案
试试这个
{% load static %}
<img src="{% get_media_prefix %}{{ product.productImagePath }}" alt="{{ product.productName }}" width="800px" height="300px">
关于python - 如何使用 python django 在 html 中显示图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44204281/