In the world of Django, there is an agreement in which you can use - there is a standard file settings.py
that imports the module local_settings
at the end, if there is one available.
You have all your sensitive materials in this local_settings.py
file and add it to .gitignore
so that it does not fall into the repository. In this way, people find out that they can add their own settings to local_settings
.
For example,
settings.py
:
DATABASE_USERNAME = 'your username here'
DATABASE_PASSWORD = 'your password here'
local_settings.py
:
DATABASE_USERNAME = 'my top secret username'
DATABASE_PASSWORD = 'my top secret password'
The best part is that everything that you define in settings.py
will be overridden by the same name in local_settings.py
.
source
share