One best practices in software development is hide ours project keys, for example: database name, password database, etc.
To carry out this practice in our projects with Django we can use the following package: Python Decouple .
First activate the project virtual enviroment:
source env/bin/activate
Install python-decouple
pip install python-decouple
Create the .env file inside folder project:
Inside file .env, write the password , path to key .json, etc... data sensible of settings project file.
this is an example:
And your settings file import your enviroment variables:
from decouple import config
Use variables inside your file:
Ready, your data sensible is hidden.
Note: The enviroment variables could use in any file.
Important: Not Upload .env file to repository
see you..
Top comments (0)