Reputation: 654
I want to host a django project on heroku. Locally, I developed it using MySQL database. And I have also pushed it to heroku but I get an Error message whenever I run heroku open
command on command prompt. The error message is Can't connect to local MySQL server through socket
. Though I'm a newbie in using databases, the way I understand the error is that heroku can't connect to local MySQL server which I'm using for local development. I don't want to connect to a remote MySQL database, instead, I want to connect to Postgre database just as heroku recommended.
Being a newbie in the use of database, I don't know the best way to migrate to Postgre or how to add MySQL in my project to .gitignore. Is it possible for me to start running Postgre on heroku while MySQL isn't added to . gitignore and is still the database in settings.py? Must I clear MySQL database or add it to gitignore before I can use Postgre?
Upvotes: 1
Views: 73
Reputation: 166
PostgreSQL settings for Heroku:
dj_database_url
using below command: pip install dj-database-url
settings.py
, import dj_database_url
and add below settings at the end of the file:import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
Done !! Now, deploy again to Heroku.
Upvotes: 2