I would like to import a local_settings.py file (which is not in my VCS system) for overriding the DATABASES settings from settings.py
For this purpose I added those lines at the very end of my settings.py file.
try:
from local_settings import *
except ImportError:
print('Unable to load local_settings.py:')
When I use a python manage.py diffsettings
I see that the DATABASES settings from settings.py is not changed and I get the message Unable to load local_settings.py:
I would like to know why import failed.
This is my project folder architecture:
my_project_folder/
my_project_folder/
settings.py
urls.py
local_settings.py
etc...
app1/
app2/
static/
manage.py
docker-compose.yml
etc...
This is the content of my local_settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
'HOST': 'db_my_project',
'PORT': 5432,
}
}
And this is the content of the DATABASES settings in settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydb',
'USER': 'my_project',
'PASSWORD': 'my_password',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
Thanks in advance for your help !