Reputation: 3608
I created one App Python:Django in Heroku, in my settings I have a set up a database from Amazon WS, so when Deploy is finished, another configurations appear.
My settings.DATABASES
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'myAppDb',
'USER': 'UserAppDb',
'PASSWORD': 'some_password',
'HOST': 'myAppDb.cohkbwwvlbxi.us-west-2.rds.amazonaws.com',
'PORT': '7878',
}
}
In console heroku I have this:
heroku run bash
python
from myapp import settings
setting.DATABASES
{'default': {'NAME': 'd7kqa751lkhqo6', 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'HOST': 'ec2-74-75-228-85.eu-west-1.compute.amazonaws.com', 'USER': 'hzhpegboxtikxk', 'PORT': 5432, 'PASSWORD': 'XfiPl1tJZB9Znk22b5UQmeYD2u', 'CONN_MAX_AGE': 500}}
In this case: NAME
, HOST
, USER
, PORT´,
PASSWORD` are tottaly diferent then I setup.
What I did wrong or didn't?
Upvotes: 0
Views: 173
Reputation: 5065
You are over-writing the database with the values you get from dj_database_url
. That is pulled from the environment variable that Heroku injects, DATABASE_URL
. From your command line, run heroku config
to see what it's set to - it will match what you see in your console session.
You can either 1) over-ride that variable (via heroku config:set
) or 2) create a new variable (also via heroku config:set
) and tell dj_database_url
to use that variable, via dj_database_url.config(env='MY_ENV_VAR')
.
Upvotes: 1