模板图像不显示与django中的媒体网址

时间:2015-07-29 08:28:30

标签: python django django-templates

在我的模板中,我已经完成了:

<img src="{{MEDIA_URL}}{{file.media_file}}"

当我检查emlement时,我得到了

<img width="100" height="100" src="/media/sta.jpg"></img>

sta.jpt文件位于我的媒体文件夹中,但它显示could not load image

这里有什么问题?

1 个答案:

答案 0 :(得分:0)

尝试将'django.template.context_processors.media'添加到TEMPLATES的'context_processors'选项中。 https://docs.djangoproject.com/en/1.8/ref/settings/#media-url