How to define two databases in django one for Production and one for Development

django, heroku, python

Solution

You can create a local_settings.py file inside your project, and import it from your base setting file. This way you can have different settings for each environment.

This local_setting file should be included in your .gitignore

Problem

I have a project that works on Heroku, I don't have PostgreSQL installed on my local machine. I want to keep running the app on my local machine using `sqlite3`, but when I push it to Heroku it will convert to `pg` All I am trying to do is to have an IF condition if this is development then run sqlite3 .. but if it's production run then following command. ``` DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': '', 'HOST': '', 'PORT': 5432, 'USER': '', 'PASSWORD': '' } } ``` Heroku is working with `dj_database_url` ``` import dj_database_url DATABASES['default'] = dj_database_url.config() ``` It basically similar to `Rails` when we define the gems for production and another gems for testing and development.

Original source

Related problems