【发布时间】:2014-12-16 20:04:52
【问题描述】:
您好,我在引用 HTML 中上传的图片时遇到问题。
我正在使用 ImageField 来保存个人资料图片:
picture = models.ImageField(upload_to='stories/static/stories/profile_images/', blank=True)
如你所见,它会上传到<App folder>/static/stories/profile_images/
然后我像这样在 HTML 中引用它:
<div class="profilepic" style="background-image: url('/{{ x.writer.picture }}');"></div>
指向
ROOT/stories/static/stories/profile_images/.jpg
代替
ROOT/static/stories/profile_images/.jpg
有什么想法吗?
(我正在尝试反向截断前 8 个字符,但没有可用的内置模板过滤器)
【问题讨论】:
标签: django imagefield