Skip to content

Instantly share code, notes, and snippets.

@PCreations
Created July 23, 2015 21:33
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 PCreations/e724c0f2caa90f3f1650 to your computer and use it in GitHub Desktop.
Save PCreations/e724c0f2caa90f3f1650 to your computer and use it in GitHub Desktop.
import os
from django.core.exceptions import ImproperlyConfigured
def get_env_variable(var_name):
""" Gets the environment variable or returns exception. """
try:
return os.environ[var_name]
except KeyError:
error_msg = "Set the {} environment variable".format(var_name)
raise ImproperlyConfigured
SECRET_KEY = get_env_variable('DJANGO_SECRET_KEY')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment