153 lines
4.0 KiB
Python
153 lines
4.0 KiB
Python
"""
|
|
Django settings for ospaz_site project.
|
|
|
|
Generated by 'django-admin startproject' using Django 5.0.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/5.0/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/5.0/ref/settings/
|
|
"""
|
|
|
|
from pathlib import Path
|
|
import os
|
|
import dotenv
|
|
from django.db.backends.postgresql.psycopg_any import IsolationLevel
|
|
|
|
|
|
dotenv.load_dotenv()
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
PROJECT_ROOT = os.path.dirname(__file__)
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
|
|
|
|
SECRET_KEY = os.getenv('DJANGO_SECRET')
|
|
|
|
ALLOWED_HOSTS = ['10.8.0.2', '10.8.0.6', 'ospaz.wawaa.ru', 'dev.ospaz.wawaa.ru']
|
|
CSRF_TRUSTED_ORIGINS = ['http://10.8.0.2', 'http://10.8.0.6', 'https://ospaz.wawaa.ru', 'https://dev.ospaz.wawaa.ru']
|
|
|
|
# HTTPS settings https://docs.djangoproject.com/en/5.0/topics/security/
|
|
#CSRF_COOKIE_SECURE = True
|
|
#SESSION_COOKIE_SECURE = True
|
|
#DEBUG = False
|
|
|
|
# HTTP settings
|
|
DEBUG = int(os.getenv('PROJECT_DEBUG', '0')) != 0
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
|
|
# custom apps
|
|
'users.apps.UsersConfig',
|
|
'index.apps.IndexConfig'
|
|
]
|
|
|
|
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 = 'ospaz_site.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [os.path.join(BASE_DIR, 'templates')],
|
|
'APP_DIRS': True,
|
|
'OPTIONS': {
|
|
'context_processors': [
|
|
'django.template.context_processors.debug',
|
|
'django.template.context_processors.request',
|
|
'django.contrib.auth.context_processors.auth',
|
|
'django.contrib.messages.context_processors.messages',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'ospaz_site.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': os.getenv('DB_NAME'),
|
|
'USER': os.getenv('DB_USERNAME'),
|
|
'PASSWORD': os.getenv('DB_PASSWORD'),
|
|
'HOST': os.getenv('DB_HOST', 'localhost'),
|
|
'PORT': os.getenv('DB_PORT', ''),
|
|
},
|
|
"OPTIONS": {
|
|
"isolation_level": IsolationLevel.SERIALIZABLE,
|
|
},
|
|
}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
|
|
|
|
AUTH_USER_MODEL = 'users.User'
|
|
|
|
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',
|
|
},
|
|
]
|
|
|
|
LOGIN_URL = "/account/login"
|
|
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/5.0/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'ru-RU'
|
|
|
|
TIME_ZONE = 'Europe/Moscow'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
|
|
|
STATIC_URL = 'static/'
|
|
STATICFILES_DIRS = [
|
|
os.path.join(BASE_DIR, 'static')
|
|
]
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|