Last active
January 27, 2025 21:33
-
-
Save pydanny/6094883 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# settings/base.py | |
import os | |
# Normally you should not import ANYTHING from Django directly | |
# into your settings, but ImproperlyConfigured is an exception. | |
from django.core.exceptions import ImproperlyConfigured | |
def get_env_variable(var_name): | |
""" Get the environment variable or return exception """ | |
try: | |
return os.environ[var_name] | |
except KeyError: | |
error_msg = "Set the %s environment variable" % var_name | |
raise ImproperlyConfigured(error_msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, this was very helpful.