Django 2.0

How To Install Apache Django Postgresql on Ubuntu 16.04 Part3

This one will be short and will be about keeping our sensitive data in a secure place instead of

I will create a new folder under /etc and  name it as crm_app_secret. Then create a file named config.json

cd /etc
sudo mkdir prj_crm_secret
sudo touch /etc/prj_crm_secret/config.json


Copy the SECRET_KEY from and paste in config.json like below.Then save it.

"SECRET_KEY":"pb))[email protected](pm4!uswdfwf6n_*+-(2-mg"


Similarly, you can add other sensitive info from such as usernames, passwords etc

We need to edit our like below to let config file to work

add these lines just after import os as you see below.

import os
import json
with open('/etc/prj_crm_secret/config.json') as config_file:
    config = json.load(config_file)


In, I need to declare that the value is in config file and add the dictionary key which I created in the config file



If you are getting username or password info from that config file, you need to use config.get not config only

EMAIL_USER = config.get('EMAIL_USER')

Post Comment