From fbfc3b492b8e0152790a2b265f080c1d61131705 Mon Sep 17 00:00:00 2001 From: erjemin Date: Fri, 26 Dec 2025 17:20:48 +0300 Subject: [PATCH] getting environment from `.env` --- etpgrf_site/etpgrf_site/asgi.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/etpgrf_site/etpgrf_site/asgi.py b/etpgrf_site/etpgrf_site/asgi.py index 875e1d6..54f35f6 100644 --- a/etpgrf_site/etpgrf_site/asgi.py +++ b/etpgrf_site/etpgrf_site/asgi.py @@ -1,16 +1,19 @@ """ ASGI config for etpgrf_site project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/6.0/howto/deployment/asgi/ """ import os - +from pathlib import Path from django.core.asgi import get_asgi_application +# Пытаемся загрузить переменные из .env файла +try: + from dotenv import load_dotenv + env_path = Path(__file__).resolve().parent.parent.parent / '.env' + load_dotenv(env_path) +except ImportError: + pass + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'etpgrf_site.settings') application = get_asgi_application()