[Fixed]-Changing from Sqllite to Postgres on Heroku- why it is not working?

1👍

If you have not already, you might need to add heroku postgres as an app in your heroku app’s dashboard.

It seems like you have used the same code that I used to connect my heroku’s postgres to heroku. You should only have to state

import dj_database_url
db_from_env = dj_database_url.config()
DATABASES['default'].update(db_from_env)

then make sure you have pip installed whitenoise and added that to requirements.txt. After commmiting, and pushing to heroku, you may want to run heroku run bash on cmd or terminal. Then you may want to run python manage.py makemigrations yourappname afterwards, you may want to run python manage.py migrate, and if you get no errors, you might want to check on your heroku dashboard for your app, clicking on postgres, to see if any of the postgres’ tables are in use. If they are, then you are using the heroku postgres.

you may not need the lines of code below for heroku

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'd4drq1yytest',
'USER': 'xvvqgkjtest',
'PASSWORD': 'test5y55y5y5y5y5y5y5y5y5y54y45',
'HOST': '777-77-77-67-7.compute-1.amazonaws.com',
'PORT': '5432',
}
}

this should be where you are calling the database you will be testing with your localhost.

Leave a comment