31 lines
936 B
Python
31 lines
936 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
DB_ENGINE = 'sqlite3'
|
|
if DB_ENGINE == "postgres":
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': os.getenv('POSTGRES_DB', default='postgres'),
|
|
'USER': os.getenv('POSTGRES_USER', default='postgres'),
|
|
'PASSWORD': os.getenv('POSTGRES_PASSWORD', default='postgres'),
|
|
'HOST': os.getenv('POSTGRES_HOST', default='db'),
|
|
'PORT': os.getenv('POSTGRES_PORT', default=5432),
|
|
}
|
|
}
|
|
|
|
elif DB_ENGINE == "sqlite3":
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': BASE_DIR / "db.sqlite3",
|
|
}
|
|
}
|
|
else:
|
|
raise ValueError("Неверное значение DB_ENGINE! Используйте 'postgres' или 'sqlite3'.")
|
|
|
|
|
|
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static/'),)
|