DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Ivan Lรณpez
Ivan Lรณpez

Posted on • Updated on

Hidden keys on django projects

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
Enter fullscreen mode Exit fullscreen mode

Create the .env file inside folder project:

.env file location

Inside file .env, write the password , path to key .json, etc... data sensible of settings project file.

this is an example:

.env example

And your settings file import your enviroment variables:

from decouple import config
Enter fullscreen mode Exit fullscreen mode

Use variables inside your file:

python decouple use

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)

๐ŸŒš Life is too short to browse without dark mode