Forked from
TO / sifrovacka
7 commits behind the upstream repository.
-
jan.bednarik authoredjan.bednarik authored
settings.py 5.28 KiB
"""
Django settings for django_apps project.
Generated by 'django-admin startproject' using Django 3.2.3.
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/
"""
from pathlib import Path
import environ
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
env = environ.Env()
environ.Env.read_env(str(BASE_DIR / ".env"))
# 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 = env.str("SECRET_KEY", default="")
# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = False
DJANGO_ENV = env.str("DJANGO_ENV", default="production").lower()
if DJANGO_ENV == "local":
DEBUG = True
elif DJANGO_ENV == "production":
DEBUG = False
ALLOWED_HOSTS = ["*"]
# Application definition
#'polls.apps.PollsConfig',
INSTALLED_APPS = [
"sifrovacka.apps.SifrovackaConfig",
"django_registration",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"tinymce",
]
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",
"whitenoise.middleware.WhiteNoiseMiddleware",
]
ROOT_URLCONF = "django_apps.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.template.context_processors.media",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
WSGI_APPLICATION = "django_apps.wsgi.application"
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
if DJANGO_ENV == "production":
DATABASES = {"default": env.db("DATABASE_URL")}
# 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 = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# 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"
# Custom settings AUTH
LOGIN_REDIRECT_URL = "home"
LOGOUT_REDIRECT_URL = "index"
# Custom settings STATIC
STATIC_ROOT = BASE_DIR / "static"
# STATICFILES_DIRS = BASE_DIR / 'static'
# Custom settings MEDIA
MEDIA_URL = "/media/"
MEDIA_ROOT = BASE_DIR / "media"
# TinyMCE settings
TINYMCE_DEFAULT_CONFIG = {
"cleanup_on_startup": True,
"custom_undo_redo_levels": 20,
"selector": "textarea",
"theme": "silver",
"plugins": """
textcolor save link image media preview codesample contextmenu
table code lists fullscreen insertdatetime nonbreaking
contextmenu directionality searchreplace wordcount visualblocks
visualchars code fullscreen autolink lists charmap print hr
anchor pagebreak
""",
"toolbar1": """
fullscreen preview bold italic underline | fontselect,
fontsizeselect | forecolor backcolor | alignleft alignright |
aligncenter alignjustify | indent outdent | bullist numlist table |
| link image media | codesample |
""",
"toolbar2": """
visualblocks visualchars |
charmap hr pagebreak nonbreaking anchor | code |
""",
"contextmenu": "formats | link image",
"menubar": True,
"statusbar": True,
}
# Custom settings Registration
ACCOUNT_ACTIVATION_DAYS = 7
EMAIL_HOST = env.str("SMTP_SERVER", default="mail2.playzone.cz")
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = env.str("SMTP_USER", default="")
EMAIL_HOST_PASSWORD = env.str("SMTP_PASSWORD", default="")
DEFAULT_FROM_EMAIL = "sifrovacka@pirati.cz"