Reputation: 441
I've just configured my remote PostgreSQL database @ Elephant but now I'd like to also set the local PostgreSQL connection in order to make some tests before going online (remote db).
This is my settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '***',
'USER': '***',
'PASSWORD': '***',
'HOST': 'lallah.db.elephantsql.com',
'PORT': '5432',
}
}
How can I update the settings.py to also let me use the localhost PostgreSQL connection without erasing the elephant configurations?
Thank you!
Upvotes: 0
Views: 248
Reputation: 756
The most common approach is to have something like local_settings.py in your project that is not a part of production dist (gitignored etc). You can define your local settings there, not only db, but caches, compress options and many more and then override production settings in main settings.py by import:
if DEBUG == True:
from .local_settings import DATABASES, CACHES # and whatever else you want
Upvotes: 1