An error occurred while loading the file. Please try again.
-
dcz2 authored5d5c05e5
settings.py 4.49 KiB
"""
Django settings for ShellValier project.
Generated by 'django-admin startproject' using Django 2.1.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
import uuid
from django.urls import reverse_lazy
from .environment import get_environment, boolean_mapper, list_mapper_factory
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = get_environment('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = get_environment('DEBUG', mapper=boolean_mapper)
# for production
'''
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
X_FRAME_OPTIONS = 'DENY'
'''
ALLOWED_HOSTS = get_environment('ALLOWED_HOSTS', mapper=list_mapper_factory())
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'common.apps.CommonConfig',
'connections.apps.ConnectionsConfig',
'examples.apps.ExamplesConfig',
'meanings.apps.MeaningsConfig',
'semantics.apps.SemanticsConfig',
'syntax.apps.SyntaxConfig',
'entries.apps.EntriesConfig',
'phrase_expansions.apps.PhraseExpansionsConfig',
'dictionary_statistics.apps.DictionaryStatisticsConfig',
'download.apps.DownloadConfig',
'users.apps.UsersConfig',
'crispy_forms',
'django_extensions',
]
CRISPY_TEMPLATE_PACK = 'bootstrap4'
CRISPY_FAIL_SILENTLY = not DEBUG
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',
'django.middleware.locale.LocaleMiddleware',
]
ROOT_URLCONF = 'shellvalier.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 = 'shellvalier.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': get_environment('DATABASE_NAME'),
'USER': get_environment('DATABASE_USER'),
'PASSWORD': get_environment('DATABASE_PASSWORD'),
'HOST': get_environment('DATABASE_HOST'),
'PORT': get_environment('DATABASE_PORT', mapper=int),
}}
# Password validation
# https://docs.djangoproject.com/en/2.1/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/2.1/topics/i18n/
LANGUAGE_CODE = 'pl'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOCALE_PATHS = [
'locale',
]
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
VERSION = get_environment('VERSION', default=str(uuid.uuid4()))
STATIC_URL = f'/static/{VERSION}/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'common/static/'),
]
LOGIN_URL = reverse_lazy("users:login")
LOGIN_REDIRECT_URL = reverse_lazy('dash')
LOGOUT_REDIRECT_URL = reverse_lazy('dash')