2025-11-18 18:30:21 +00:00
|
|
|
from pathlib import Path
|
2025-11-19 12:55:53 +00:00
|
|
|
import os
|
2025-11-18 18:30:21 +00:00
|
|
|
|
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
|
|
|
|
|
2025-11-19 12:55:53 +00:00
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
load_dotenv(dotenv_path = BASE_DIR / '.env')
|
|
|
|
|
|
|
|
|
|
|
2025-11-18 18:30:21 +00:00
|
|
|
# Quick-start development settings - unsuitable for production
|
|
|
|
|
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
|
|
|
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
2025-11-19 12:55:53 +00:00
|
|
|
# Prefer setting `DJANGO_SECRET_KEY` in the repository `.env` file or in
|
|
|
|
|
# the deployment environment. A fallback is kept for local convenience.
|
|
|
|
|
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY', 'django-insecure-pf#9a$@vq1o91n#mxwba_dm-+v9&*u4f3$#bts%zanu-$0*whk')
|
2025-11-18 18:30:21 +00:00
|
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
2025-11-19 12:55:53 +00:00
|
|
|
# Set `DJANGO_DEBUG=false` in production environments.
|
|
|
|
|
_debug_env = os.getenv('DJANGO_DEBUG', 'True')
|
|
|
|
|
DEBUG = str(_debug_env).lower() in ('1', 'true', 'yes', 'on')
|
2025-11-18 18:30:21 +00:00
|
|
|
|
2025-11-19 12:55:53 +00:00
|
|
|
# ALLOWED_HOSTS can be provided as a comma-separated list in `DJANGO_ALLOWED_HOSTS`.
|
|
|
|
|
_hosts = os.getenv('DJANGO_ALLOWED_HOSTS', '')
|
|
|
|
|
ALLOWED_HOSTS = [h.strip() for h in _hosts.split(',') if h.strip()]
|
2025-11-18 18:30:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
2025-11-19 12:55:53 +00:00
|
|
|
DJANGO_APPS = [
|
2025-11-18 18:30:21 +00:00
|
|
|
'django.contrib.admin',
|
|
|
|
|
'django.contrib.auth',
|
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
|
'django.contrib.sessions',
|
|
|
|
|
'django.contrib.messages',
|
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
|
]
|
|
|
|
|
|
2025-11-19 12:55:53 +00:00
|
|
|
THIRD_PARTY_APPS = [
|
|
|
|
|
'rest_framework',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
LOCAL_APPS = [
|
|
|
|
|
'apps.users',
|
|
|
|
|
'apps.domains',
|
|
|
|
|
'apps.agents',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AUTH_USER_MODEL = 'users.User'
|
|
|
|
|
|
2025-11-18 18:30:21 +00:00
|
|
|
MIDDLEWARE = [
|
|
|
|
|
'django.middleware.security.SecurityMiddleware',
|
|
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
ROOT_URLCONF = 'config.urls'
|
|
|
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
|
{
|
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
|
'DIRS': [],
|
|
|
|
|
'APP_DIRS': True,
|
|
|
|
|
'OPTIONS': {
|
|
|
|
|
'context_processors': [
|
|
|
|
|
'django.template.context_processors.request',
|
|
|
|
|
'django.contrib.auth.context_processors.auth',
|
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
WSGI_APPLICATION = 'config.wsgi.application'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Database
|
|
|
|
|
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
|
|
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
|
'default': {
|
|
|
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
|
'NAME': BASE_DIR / 'db.sqlite3',
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-19 12:55:53 +00:00
|
|
|
# Allow overriding sqlite file via DJANGO_DB_NAME environment variable (relative to project root).
|
|
|
|
|
_db_name = os.getenv('DJANGO_DB_NAME')
|
|
|
|
|
if _db_name:
|
|
|
|
|
DATABASES['default']['NAME'] = BASE_DIR / _db_name
|
|
|
|
|
|
2025-11-18 18:30:21 +00:00
|
|
|
|
|
|
|
|
# Password validation
|
|
|
|
|
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
|
|
|
|
|
|
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
|
|
|
{
|
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Internationalization
|
|
|
|
|
# https://docs.djangoproject.com/en/5.2/topics/i18n/
|
|
|
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
|
|
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
|
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
|
|
|
|
|
|
|
|
|
STATIC_URL = 'static/'
|
2025-11-18 21:39:01 +00:00
|
|
|
STATIC_ROOT = 'static/'
|
2025-11-18 18:30:21 +00:00
|
|
|
|
|
|
|
|
# Default primary key field type
|
|
|
|
|
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
|
|
|
|
|
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
2025-11-19 12:55:53 +00:00
|
|
|
|
|
|
|
|
# Django REST framework basic configuration for the POC. Adjust auth/permissions
|
|
|
|
|
# as features become defined. For production, tighten permissions and use token
|
|
|
|
|
# or JWT authentication as appropriate.
|
|
|
|
|
REST_FRAMEWORK = {
|
|
|
|
|
'DEFAULT_AUTHENTICATION_CLASSES': [
|
|
|
|
|
'rest_framework.authentication.SessionAuthentication',
|
|
|
|
|
'rest_framework.authentication.BasicAuthentication',
|
|
|
|
|
],
|
|
|
|
|
'DEFAULT_PERMISSION_CLASSES': [
|
|
|
|
|
'rest_framework.permissions.AllowAny',
|
|
|
|
|
],
|
|
|
|
|
}
|