How to display media files stored in Amazon S3 in Django template?


I have integrated Amazon S3 with my Django app. A media folder has been created in my S3 bucket, and when users upload a file it shows up there just fine. What I’m unclear about is how to display these files in the template. Currently the code is:

I’ve also tried:

Another thing to keep in mind is when I try to access these files from the S3 account I get this output. Not sure if this is a permissions issue or what. However, in the admin the image shows up fine.

  • No longer getting access denied-I made access public (Not sure if this is the only/best way to do it). Still unclear on how to display it in template. The url gives a 404 error.
  • In Admin the file path is /folder/file.jpg, but in the template the file path is /media/folder/file.jpg. I think this could be the source of the problem, but not sure why media is there.

Any help would be appreciated.


This answer can also be found at Getting MEDIA images on Amazon S3 server on template so if mods feel this is not needed feel free to delete.

Super simple. All you have to do is:

Leave a Reply