""" Django settings for pflaenzli_django project. Generated by 'django-admin startproject' using Django 4.1.5. 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 from dotenv import load_dotenv # Parse .env load_dotenv() # 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 = "django-insecure-q=ps#iypevr!3zfpwtfp3lw#4r3%oyj*(2=*iq^8f4_zbodi^(" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = os.getenv('DJANGO_ALLOWED_HOSTS', 'localhost').split(',') CSRF_TRUSTED_ORIGINS = os.getenv('DJANGO_CSRF_TRUSTED_ORIGINS', 'http://localhost:8080').split(',') # Application definition INSTALLED_APPS = [ "pflaenzli", "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "fontawesomefree", "crispy_forms", "crispy_bootstrap5", "friendly_captcha", "django.contrib.sitemaps", "djangoloco", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", 'django.middleware.locale.LocaleMiddleware', "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.common.CommonMiddleware", ] ROOT_URLCONF = "pflaenzli_django.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 = "pflaenzli_django.wsgi.application" # Database # https://docs.djangoproject.com/en/4.1/ref/settings/#databases if os.getenv('POSTGRES_DB') is not None: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': os.getenv('POSTGRES_DB'), 'USER': os.getenv('POSTGRES_USER'), 'PASSWORD': os.getenv('POSTGRES_PASSWORD'), 'HOST': 'db', 'PORT': '5432', } } else: DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DIR / "db.sqlite3", } } # Password validation # https://docs.djangoproject.com/en/4.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", }, ] AUTH_USER_MODEL = 'pflaenzli.PflaenzliUser' LOGIN_REDIRECT_URL = "/load_language" LOGOUT_REDIRECT_URL = "/" # Internationalization # https://docs.djangoproject.com/en/4.1/topics/i18n/ LANGUAGE_CODE = 'de' LANGUAGES = [ ('de', 'German'), ('en', 'English'), ] TIME_ZONE = "Europe/Zurich" USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.1/howto/static-files/ STATIC_URL = "static/" MEDIA_ROOT = os.path.join(BASE_DIR, "media") MEDIA_URL = "media/" STATIC_ROOT = "/app/pflaenzli/static_collected" # Default primary key field type # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" CRISPY_TEMPLATE_PACK = 'bootstrap5' # Email Settings # SMTP Server EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = os.getenv('SMTP_HOST') EMAIL_PORT = os.getenv('SMTP_PORT') DEFAULT_FROM_EMAIL = 'no-reply@pflaenz.li' EMAIL_HOST_USER = os.getenv('SMTP_USER') EMAIL_HOST_PASSWORD = os.getenv('SMTP_PASSWORD') EMAIL_USE_SSL = True # Friendly Captcha setting FRC_CAPTCHA_SECRET = os.getenv('FRC_SECRET') FRC_CAPTCHA_SITE_KEY = os.getenv('FRC_SITEKEY') FRC_CAPTCHA_VERIFICATION_URL = 'https://api.friendlycaptcha.com/api/v1/siteverify' # Loco translation managment LOCO_API_KEY = os.getenv('LOCO_API_KEY') # Image compression settings IMAGE_MAX_SIZE = 1500 # Long edge size IMAGE_QUALITY = 75 # 0-100%