import os
from pathlib import Path
from typing import Dict

from django.contrib.admin import AdminSite

from common.utils import Config

BASE_DIR = Path(__file__).resolve(strict=True).parent.parent.parent

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
CONFIG_FILE = os.path.join(BASE_DIR, "..", "config.yml")
config = Config(CONFIG_FILE)

AdminSite.site_title = config.get("SITE_TITLE", "Django Template Project")
AdminSite.site_header = config.get("SITE_HEADER", "Django Template Project")
AdminSite.index_title = config.get("INDEX_TITLE", "Django Template Administration")
SECRET_KEY = config.get("SECRET_KEY", raise_error=True)
DEBUG = config.get("DEBUG", False, cast=bool)
ALLOWED_HOSTS = config.get("ALLOWED_HOSTS", cast=list)

INSTALLED_APPS = [
    "administration",
    "common",
    "rest_framework",
    "drf_spectacular",
    "corsheaders",
    "django.contrib.contenttypes",
    "jazzmin",
    "django.contrib.admin",
Example #2
0
import os
from pathlib import Path

from common.utils import Config

BASE_DIR = Path(__file__).resolve(strict=True).parent

CONFIG_FILE = os.path.join(BASE_DIR, "..", "config.yml")
config = Config(CONFIG_FILE)

config.get("DB_NAME", raise_error=True)
config.get("DB_PASSWORD", raise_error=True)