Database are deleting after every deployment to DigitalOcean App Platform - Django

I did my first deployment to DigitalOcean using App Platform, but I have a problem with Database of Django project

Every time i implement some new code or some changes. PostgreSQL database removes all registered data, admin users, posts, … Why is this problem happening? I appreciate any information. I did the deployment according to:

I appreciate your help, thanks

My DB settings:

if not DEBUG:
    # Postgresql config
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': os.environ.get('DB_NAME'),
            'USER': os.environ.get('DB_USER'),
            'PASSWORD': os.environ.get('DB_USER_PASSWORD'),
            'HOST': os.environ.get('DB_HOST'),
            'PORT': os.environ.get('DB_PORT'),
            'SSLMODE': os.environ.get('DB_SSLMODE'),

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 4, 2022

Hi there,

The App platform uses ephemeral storage, meaning that after each deployment all the files that were stored on the App platform itself would be lost.

You should use a Managed Database with your app rather than running your database inside the App Platform itself:

And for static files like images, you could use Spaces for persistent storage:

For more information on how to store data in the App Platform, I would recommend the official docs here:

Hope that this helps!