Django Production Settings (3) – django-environ and .env file

As explained on the previous page, we need to manage confidential data relating to the Django app settings. To separate the settings, you can use the django-environ library.

django-environ

django-environ allows you to configure the Django application using environment variables obtained from an environment file and provided by the OS.

Basically, using this library, you can separately manage confidential information in another file named .env.

Settings written in the .env file

Confidential data should be put in the .env file. Most confidential data are already included in the settings for production explained on the previous page, except SECRET_KEY. SECRET_KEY is not specific for production, but it should be confidentially managed and saved under the .env file.

IdeaNote: SECRET_KEY

Accordin