code: def get_env_variable(var_name, default=None):
      
      try:
          return os.environ[var_name]
      except KeyError:
          if default is None:
              error_msg = "Set the %s environment variable" % var_name
              raise ImproperlyConfigured(error_msg)
          else:
              return default
docs: Get the environment variable or return exception.