import os import os.path PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)) local_import = "env/development.py" if os.getenv("DJANGO_ENV") == 'TEST': local_import = "env/test.py" elif os.getenv("DJANGO_ENV") == 'PRODUCTION': local_import = "env/production.py" import_file = open(os.path.join(PROJECT_ROOT, local_import)) exec(import_file)