getting environment from .env

This commit is contained in:
2025-12-26 17:20:48 +03:00
parent d3f1f2691f
commit fbfc3b492b

View File

@@ -1,16 +1,19 @@
""" """
ASGI config for etpgrf_site project. 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 import os
from pathlib import Path
from django.core.asgi import get_asgi_application 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') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'etpgrf_site.settings')
application = get_asgi_application() application = get_asgi_application()