python – DJANGO with docker and postgresql

python – DJANGO with docker and postgresql

This may not be the only issue, but notice how I changed the ENGINE value to django.db.backends.postgresql_psycopg2, since you are using psycopg2. I dont remember the exact reason for this, but it has to do with the fact that you are using python-alpine image, I had a similar problem a while back.

Here, I use db as database HOST, because that is the service name inside my docker-compose.yml file, but the way you are doing it should work as well.

DATABASES = {
    default: {
        ENGINE: django.db.backends.postgresql_psycopg2,
        HOST: db,
        PORT: 5432,
        NAME: os.environ.get(POSTGRES_DB),
        USER: os.environ.get(POSTGRES_USER),
        PASSWORD: os.environ.get(POSTGRES_PASSWORD)
    }
}

Also, I didnt really understand your issue, but this is something I saw was wrong.

python – DJANGO with docker and postgresql

Leave a Reply

Your email address will not be published.