-1

whenever i run a new deployment on heroku, all already uploaded files will be removed, It's a Django application which i deployed on heroku through my github repository, please how can i stop this from happening? Any help will be appreciated.

  • 1
    You need to explain what exactly you're doing to deploy. Normally, when updating your code, nothing changes. One thing perhaps: Where is your MEDIA_ROOT? It **must be outside of your source directory**. i.e. if /path/to/project/ contains your repository (the manage.py file is inside the project/ directory) then your MEDIA_ROOT must be above project/, i.e. in /path/ or path/to/ but not inside project/. – dirkgroten Dec 04 '19 at 17:29
  • Hmm, i think this is where the problem lies, i have my repository inside my project folder and MEDIA_ROOT is also inside the project directory, my project name is PNM, does this mean i have to make the MEDIA_ROOT outside PNM folder? – Segun Isreal Dec 04 '19 at 17:39
  • Yes of course. It can be anywhere on your drive as long as it's not inside your git repository. But I'm not entirely sure how Heroku treats a volume and whether it persists files. Heroku explicitly warns agains it (see the answer below) and has a tutorial on [how to use S3 for file storage](https://devcenter.heroku.com/articles/s3-upload-python). – dirkgroten Dec 04 '19 at 17:40

1 Answers1

1

As per the docs, "... the filesystem on Heroku is not suitable for persistent storage of data. In cases where you need to store data we recommend using a database addon such as Postgres (for data) or a dedicated file storage service such as AWS S3 (for static files). ".

FiddleStix
  • 3,016
  • 20
  • 21