getting environment from .env
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user