Skip to content

Instantly share code, notes, and snippets.

@alexryabtsev
Created April 4, 2019 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexryabtsev/5f8ff261bcf8e0e2274cbb0b827eeedb to your computer and use it in GitHub Desktop.
Save alexryabtsev/5f8ff261bcf8e0e2274cbb0b827eeedb to your computer and use it in GitHub Desktop.
import os
from django.core.exceptions import ImproperlyConfigured
def get_env_value(env_variable):
try:
return os.environ[env_variable]
except KeyError:
error_msg = 'Set the {} environment variable'.format(var_name)
raise ImproperlyConfigured(error_msg)
SECRET_KEY = get_env_value('SECRET_KEY')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': get_env_value('DATABASE_NAME'),
'HOST': get_env_value('DATABASE_HOST'),
'PORT': int(get_env_value('DATABASE_PORT')),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment