214 lines
5.6 KiB
Python
214 lines
5.6 KiB
Python
"""
|
|
Django settings for data_helper project.
|
|
|
|
Generated by 'django-admin startproject' using Django 3.2.12.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/3.2/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/3.2/ref/settings/
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = "django-insecure-%erkv*0u@b8jj5=-k5+#e_gvlbdky63n2s(anj9nzu!p^(1fbg"
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = True
|
|
|
|
WEB_PORT = os.getenv("WEB_PORT")
|
|
BASE_HOST = os.getenv("BASE_HOST", "192.168.88.107")
|
|
BASE_HOST_WITH_PORT = f"{BASE_HOST}:{WEB_PORT}"
|
|
BASE_HOST_WITH_PORT_DEV = f"{BASE_HOST}:8000"
|
|
|
|
ALLOWED_HOSTS = [
|
|
BASE_HOST,
|
|
BASE_HOST_WITH_PORT,
|
|
BASE_HOST_WITH_PORT_DEV,
|
|
"ecp.svs-tech.pro",
|
|
"ecp-dev.svs-tech.pro",
|
|
"app",
|
|
]
|
|
ALLOWED_CLIENT_ORIGINS = [
|
|
"http://localhost:3000",
|
|
f"http://{BASE_HOST}",
|
|
f"http://{BASE_HOST_WITH_PORT}",
|
|
f"http://{BASE_HOST_WITH_PORT_DEV}",
|
|
"http://ecp.svs-tech.pro",
|
|
"http://ecp-dev.svs-tech.pro",
|
|
]
|
|
CORS_ORIGIN_ALLOW_ALL = False
|
|
CSRF_TRUSTED_ORIGINS = ALLOWED_CLIENT_ORIGINS
|
|
CORS_ORIGIN_WHITELIST = ALLOWED_CLIENT_ORIGINS
|
|
|
|
CORS_ALLOW_HEADERS = [
|
|
"accept",
|
|
"accept-encoding",
|
|
"authorization",
|
|
"content-type",
|
|
"dnt",
|
|
"origin",
|
|
"user-agent",
|
|
"x-csrftoken",
|
|
"x-requested-with",
|
|
"x-terminal-id",
|
|
]
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"daphne",
|
|
"admin_interface",
|
|
"colorfield",
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"corsheaders",
|
|
"django_filters",
|
|
"django_extensions",
|
|
"rest_framework",
|
|
"crispy_forms",
|
|
"crispy_bootstrap4",
|
|
"django_eventstream",
|
|
"django_celery_beat",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"corsheaders.middleware.CorsMiddleware",
|
|
"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 = "data_helper.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [],
|
|
"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 = "data_helper.wsgi.application"
|
|
ASGI_APPLICATION = "data_helper.asgi.application"
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.postgresql_psycopg2", # change engine to this
|
|
"NAME": os.getenv("DB_NAME"),
|
|
"HOST": os.getenv("DB_HOST"),
|
|
"USER": os.getenv("DB_USER"),
|
|
"PASSWORD": os.getenv("DB_PASSWORD"),
|
|
"PORT": os.getenv("DB_PORT"),
|
|
}
|
|
}
|
|
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/3.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/3.2/topics/i18n/
|
|
|
|
LANGUAGE_CODE = "ru-ru"
|
|
|
|
TIME_ZONE = "Europe/Moscow"
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
CELERY_BROKER_URL = f'redis://{os.getenv("REDIS_NAME", "redis")}:6379/0'
|
|
CELERY_RESULT_BACKEND = f'redis://{os.getenv("REDIS_NAME", "redis")}:6379/0'
|
|
CELERY_ACCEPT_CONTENT = ["json"]
|
|
CELERY_TASK_SERIALIZER = "json"
|
|
CELERY_RESULT_SERIALIZER = "json"
|
|
CELERY_TIMEZONE = "Europe/Moscow"
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
|
|
|
STATIC_URL = "/static/"
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
LOGGING = {
|
|
"version": 1,
|
|
"disable_existing_loggers": False,
|
|
"formatters": {
|
|
"verbose": {
|
|
"format": "{levelname} {asctime} {module} {process:d} {thread:d} {message}",
|
|
"style": "{",
|
|
},
|
|
"large": {
|
|
"format": "%(asctime)s %(levelname)s %(process)d %(filename)s:%(lineno)d "
|
|
+ "%(funcName)s %(message)s "
|
|
},
|
|
"simple": {
|
|
"format": "{levelname} {asctime} {module} {message}",
|
|
"style": "{",
|
|
},
|
|
},
|
|
"handlers": {
|
|
"console": {
|
|
"level": "INFO",
|
|
"class": "logging.StreamHandler",
|
|
"formatter": "large",
|
|
},
|
|
},
|
|
"root": {
|
|
"handlers": ["console"],
|
|
"level": "INFO",
|
|
},
|
|
} |