1
在heroku域上,我無法加載我的媒體(通過使用ImageField屬性保存的圖像)文件圖像。但是,我能看到保存在靜態字段的圖像,如果我設置debug = True
將Heroku用於Django媒體文件
我保存使用以下命令我的圖片:
image = models.ImageField(upload_to=upload_location, null=True, blank=True, width_field="width_field", height_field = "height_field")
,我能夠做參考他們在我的模板someething這樣的:
<img src="{{ instance.image.url }}" class="img-responsive">
凡實例從我views.py通過像這樣:
instance = get_object_or_404(Post,slug=slug)
if instance.draft or instance.publish > timezone.now().date():
if not request.user.is_staff or not request.user.is_superuser:
raise Http404
share_string = quote_plus(instance.content)
context = {
"title": "Detail",
"instance": instance,
"share_string":share_string,
}
return render(request,"post_detail.html",context)
感謝
您仍然沒有提供任何關於如何嘗試提供這些文件的信息。 –