Jesse
Jesse

Reputation: 41

Images not loading when deploying Django app to Heroku

I deployed my app to heroku: https://doggos-only.herokuapp.com/

The images on the Dog Images link work locally, but they do not work on the deployed version. The only useful error I'm getting is: cj_eOAaboi.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)

My best guess is that it has something to do with the file path, but I'm not sure. I've tried looking around the web for a solution but have been unable to find one. Looking for any help, here is the repo: https://github.com/jpchato/doggos_only_project

I'm deploying from the deploy_branch in my repo.

Upvotes: 0

Views: 706

Answers (1)

Daniel Diaz
Daniel Diaz

Reputation: 454

That's because media files (Those files uploaded by the user) in heroku are not persistent, that means that after a certain time all the media will be erased.

I strongly suggest you to use a media CDN like cloudinary or amazon s3.

I wrote a post on how to setup a media CDN with cloudinary for free and you can access it right here

Django Tutorial: Set up Media files in Deployment for FREE

Upvotes: 2

Related Questions