mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 21:10:38 +03:00
166 lines
4.7 KiB
Python
166 lines
4.7 KiB
Python
![]() |
"""
|
||
|
Django settings for project.
|
||
|
|
||
|
Generated by 'django-admin startproject' using Django 4.1.7.
|
||
|
|
||
|
For more information on this file, see
|
||
|
https://docs.djangoproject.com/en/4.1/topics/settings/
|
||
|
|
||
|
For the full list of settings and their values, see
|
||
|
https://docs.djangoproject.com/en/4.1/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/4.1/howto/deployment/checklist/
|
||
|
|
||
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||
|
SECRET_KEY = os.environ.get('SECRET_KEY', 'not-a-secret')
|
||
|
|
||
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||
|
DEBUG = os.environ.get('DEBUG', True) in [True, 'True', '1']
|
||
|
|
||
|
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '*').split(';')
|
||
|
|
||
|
INTERNAL_IPS = [
|
||
|
"127.0.0.1",
|
||
|
]
|
||
|
|
||
|
|
||
|
INSTALLED_APPS = [
|
||
|
'django.contrib.admin',
|
||
|
'django.contrib.auth',
|
||
|
'django.contrib.contenttypes',
|
||
|
'django.contrib.sessions',
|
||
|
'django.contrib.messages',
|
||
|
'django.contrib.staticfiles',
|
||
|
|
||
|
'django_filters',
|
||
|
'rest_framework',
|
||
|
'corsheaders',
|
||
|
|
||
|
'apps.users',
|
||
|
'apps.rsform',
|
||
|
]
|
||
|
|
||
|
|
||
|
REST_FRAMEWORK = {
|
||
|
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
|
||
|
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
|
||
|
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||
|
'rest_framework.authentication.SessionAuthentication',
|
||
|
],
|
||
|
'DEFAULT_PERMISSION_CLASSES': [
|
||
|
'rest_framework.permissions.AllowAny'
|
||
|
],
|
||
|
'DEFAULT_FILTER_BACKENDS': [
|
||
|
'django_filters.rest_framework.DjangoFilterBackend'
|
||
|
],
|
||
|
}
|
||
|
|
||
|
|
||
|
CORS_ORIGIN_ALLOW_ALL = True
|
||
|
CORS_ALLOW_CREDENTIALS = True
|
||
|
# TODO: use env setup to populate allowed_origins in production
|
||
|
CSRF_TRUSTED_ORIGINS = os.environ.get('CSRF_TRUSTED_ORIGINS', 'http://localhost:3000').split(';')
|
||
|
CORS_ALLOWED_ORIGINS = os.environ.get('CORS_ALLOWED_ORIGINS', 'http://localhost:3000').split(';')
|
||
|
|
||
|
|
||
|
MIDDLEWARE = [
|
||
|
'django.middleware.security.SecurityMiddleware',
|
||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||
|
'corsheaders.middleware.CorsMiddleware',
|
||
|
'django.middleware.common.CommonMiddleware',
|
||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||
|
]
|
||
|
|
||
|
ROOT_URLCONF = 'project.urls'
|
||
|
LOGIN_URL = '/accounts/login/'
|
||
|
LOGIN_REDIRECT_URL = '/home'
|
||
|
LOGOUT_REDIRECT_URL = '/home'
|
||
|
|
||
|
TEMPLATES = [
|
||
|
{
|
||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||
|
'DIRS': [str(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 = 'project.wsgi.application'
|
||
|
|
||
|
|
||
|
# Database
|
||
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
|
||
|
|
||
|
DATABASES = {
|
||
|
'default': {
|
||
|
'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.sqlite3'),
|
||
|
'NAME': os.environ.get('DB_NAME', BASE_DIR / 'db.sqlite3'),
|
||
|
'USER': os.environ.get('DB_USER'),
|
||
|
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||
|
'HOST': os.environ.get('DB_HOST'),
|
||
|
'DB_PORT': os.environ.get('DB_PORT'),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
# Password validation
|
||
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
|
||
|
|
||
|
AUTH_PASSWORD_VALIDATORS = [
|
||
|
# NOTE: Password validators disabled
|
||
|
# {
|
||
|
# '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/4.1/topics/i18n/
|
||
|
|
||
|
LANGUAGE_CODE = 'ru'
|
||
|
TIME_ZONE = 'Europe/Moscow'
|
||
|
USE_I18N = True
|
||
|
USE_TZ = True
|
||
|
|
||
|
|
||
|
# Static files (CSS, JavaScript, Images)
|
||
|
# https://docs.djangoproject.com/en/4.1/howto/static-files/
|
||
|
|
||
|
STATIC_ROOT = os.environ.get('STATIC_ROOT', os.path.join(BASE_DIR, 'static'))
|
||
|
STATIC_URL = 'static/'
|
||
|
MEDIA_ROOT = os.environ.get('MEDIA_ROOT', os.path.join(BASE_DIR, 'media'))
|
||
|
MEDIA_URL = 'media/'
|
||
|
|
||
|
# Default primary key field type
|
||
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
||
|
|
||
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|