【发布时间】:2021-06-26 12:03:17
【问题描述】:
我需要显示具有可变路径的图像,因为用户输入的图像..
如果我提供像 <img height='200px' src="http://127.0.0.1:8000/media/images/photo.jpeg" alt="Image of student"> 这样的网址,它可以工作,但是,当我将其更改为<img src="{{ result.image_of_student.url }}" alt="Image of student"> 时,它就不起作用了
我该如何进行这项工作,因为每个网址都不同。
在教程中,他们使用了<img src={{ result.image_of_student.path}} alt="Image of student">
这对他们有用,但对我无效
【问题讨论】:
-
我建议在某处打印 "{{ result.image_of_student.url }}" 并查看该变量的值。也许
result是空的...... -
不,其他所有内容都正确显示,并且 url 也显示在 html 中。它不会仅显示在 pdf 中 @hansTheFranz