Migrate DB on Railway: ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value

248 Views Asked by At

I want to migrate my db to Railway Postgres. I put my DATABASE_URL as a env variable in prod.env file:

DATABASE_URL='postgresql://postgres:(my password here)[email protected]:6902/railway'

Here how I import it in my prod settings file:

DATABASE_URL = os.getenv("DATABASE_URL")
DATABASES = {
    "default": dj_database_url.config(default=DATABASE_URL, conn_max_age=1800),
}

When I try to migrate the db:

./manage.py migrate --settings=app.settings.prod 

I get an error:

django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check the settings documentation for more details.

I used the same approach when I migrated my DB to Heroku, and it worked well. I checked that correct value comes DATABASE_URL to prod settings file when I debug it.

I also added DATABASE_URL as a variable to my Railway project.

UPD. I tried to hardcode my DATABASE_URL in the settings file, and it worked well. But again, even when I print my DATABASES after this code:

   DATABASES = {
    "default": dj_database_url.config(default=DATABASE_URL, conn_max_age=1800),
}

I see that the values are correct.

How can I resolve this?

0

There are 0 best solutions below