cofigurate settings

This commit is contained in:
behruz-dev
2025-07-14 14:47:27 +05:00
parent a36cd4e452
commit 2040e43585
7 changed files with 51 additions and 15 deletions

View File

@@ -0,0 +1 @@
venv

0
config/conf/__init__.py Normal file
View File

18
config/env.py Normal file
View File

@@ -0,0 +1,18 @@
import os
import environ
environ.Env.read_env(os.path.join('.env'))
env = environ.Env(
DB_ENGINE=(str, 'django.db.backends.postgresql'),
DB_NAME=(str),
DB_USER=(str, 'postgres'),
DB_PASSWORD=(str),
DB_HOST=(str, 'localhost'),
DB_PORT=(int, 5432),
DEBUG=(bool, False),
ALLOWED_HOSTS=(list, ['localhost', '127.0.0.1']),
SECRET_KEY=(str)
)

View File

@@ -1,5 +1,6 @@
from pathlib import Path from pathlib import Path
from config.env import env
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent BASE_DIR = Path(__file__).resolve().parent.parent.parent
@@ -8,17 +9,16 @@ BASE_DIR = Path(__file__).resolve().parent.parent.parent
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-p4ybgfc_5v7@l8ocv9$8%i!(kn2ey$@l#k6rg=fux-n41!(3&e' SECRET_KEY = env.str('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = env.bool("DEBUG")
ALLOWED_HOSTS = [] ALLOWED_HOSTS = env.list('ALLOWED_HOSTS')
# Application definition # Application definition
DJANGO_APPS = [
INSTALLED_APPS = [
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
@@ -27,6 +27,22 @@ INSTALLED_APPS = [
'django.contrib.staticfiles', 'django.contrib.staticfiles',
] ]
APPS = [
'core.apps.shared',
'core.apps.accounts',
'core.apps.contracts',
]
PACKAGES = [
]
INSTALLED_APPS = []
INSTALLED_APPS += DJANGO_APPS
INSTALLED_APPS += PACKAGES
INSTALLED_APPS += APPS
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
@@ -55,26 +71,24 @@ TEMPLATES = [
] ]
WSGI_APPLICATION = 'config.wsgi.application' WSGI_APPLICATION = 'config.wsgi.application'
ASGI_APPLICATION = 'config.asgi.application'
# Database # Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases # https://docs.djangoproject.com/en/5.2/ref/settings/#databases
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql', 'ENGINE': env.str('DB_ENGINE'),
'NAME': 'trustme_db', 'NAME': env.str('DB_NAME'),
'USER': 'postgres', 'USER': env.str('DB_USER'),
'PASSWORD': '20090912', 'PASSWORD': env.str('DB_PASSWORD'),
'HOST': 'db', 'HOST': env.str('DB_HOST'),
'PORT': 5432, 'PORT': env.int('DB_PORT'),
} }
} }
# Password validation # Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',

View File

@@ -0,0 +1 @@
from config.settings.base import *

View File

@@ -0,0 +1 @@
from config.settings.base import *

View File

@@ -2,3 +2,4 @@ django==5.2
gunicorn gunicorn
uvicorn uvicorn
psycopg2 psycopg2
django-environ==0.12.0