On the heroku domain, I am not able to load my Media(Images Saved by using ImageField property) file images. However, I am able to see the images saved in the static field if I set debug = True
I save my images using the following command:
image = models.ImageField(upload_to=upload_location, null=True, blank=True, width_field="width_field", height_field = "height_field")
And I am able to reference them in my template by doing someething like this:
<img src="{{ instance.image.url }}" class="img-responsive">
Where instance is passed from my views.py like so:
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)
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…