在heroku域上,我无法加载我的媒体(使用ImageField属性保存的图像)文件图像.但是,如果我设置,我能够看到保存在静态字段中的图像debug = True
我使用以下命令保存我的图像:
image = models.ImageField(upload_to=upload_location, null=True, blank=True, width_field="width_field", height_field = "height_field")
Run Code Online (Sandbox Code Playgroud)
我能够通过这样的方式在我的模板中引用它们:
<img src="{{ instance.image.url }}" class="img-responsive">
Run Code Online (Sandbox Code Playgroud)
从我的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)
Run Code Online (Sandbox Code Playgroud)
谢谢
如果我在Heroku上托管一个小的Django网站并且我只使用一个dyno,那么它是否可以保存到该服务器上的媒体文件,或者我是否必须使用AWS S3存储来存储媒体文件?媒体存储的其他替代方案是什么?