djangoherokuheroku-postgresheroku-toolbelt

Heroku Database


Good day, I have a Django app that I hosted on Heroku with the codes from GitHub, it deployed fine and I have a domain, for instance myapp.herokuapp.com. But when I make some changes to the website itself, everything seems alright, then I make changes in the code and push it to GitHub. It deploys again perfectly, but all the former changes I made on the website get discarded, it now looks like a fresh deployed app. Auto-deploy from GitHub is enabled in my Heroku settings.

how can I retain changes I make on the Heroku website after updating my code??


Solution

  • Heroku Dynos have an ephemeral file system therefore it cannot be used to persist data (at every redeployment all local changes are discarded).

    You can use a database, either external (MongoDB Atlas) or the Heroku Postgres, both have a free tier.

    If you need to save simple files you can use an external storage service (S3, Dropbox, even GitHub). See Files on Heroku for details and examples.