💦Python-Decouple

Python Decouple

Decouple helps you to organize your settings so that you can change parameters without having to redeploy your app.

It also makes it easy for you to:

  1. store parameters in ini or .env files;

  2. define comprehensive default values;

  3. properly convert values to the correct data type;

  4. have only one configuration module to rule all your instances.

It was originally designed for Django but became an independent generic tool for separating settings from code.

Install:

pip install python-decouple

Then use it on your settings.py.

Import the config object:

from decouple import config, Csv

Retrieve the configuration parameters:

SECRET_KEY = config('SECRET_KEY')
DEBUG = config('DEBUG', default=False, cast=bool)

For Allowed Host:

Postgres database config:

circle-info

Decouple supports both .iniand .env files.

Last updated