rf_django_envconfig

rf_django_envconfig.get_bool(env, name, default=False)[source]

Get a boolean value from the environment

If name is not found in env, return True if default evaluates to True, otherwise return False.

The following values are considered False:

  • 'False'
  • 'false'
  • 'Off'
  • 'off'
  • '0'
  • 'No'
  • 'no'
  • ''

Any other value is considered True.

rf_django_envconfig.get_db_url(env, name, default='')[source]

Get a settings.DATABASES entry from a URL in the environment

This is just a thin convenience wrapper around dj-database-url.

If name is not found in env, return the result of parsing default.

DATABASES = {
    'default': get_db_url(
        os.environ,
        'DATABASE_URL',
        default='postgres://myuser:mypassword@localhost/myproject'
    )
}
rf_django_envconfig.get_list(env, name, default=None)[source]

Get a list from the environment

The input is assumed to be a comma-separated list of strings.

If name is not found in env, return default. Note that default is returned as-is, so you should usually specify it as a list:

ALLOWED_HOSTS = get_list(os.environ, 'ALLOWED_HOSTS', ['localhost', ])