right-tree/backend/right_tree/settings.py

156 lines
4.2 KiB
Python
Raw Normal View History

2021-10-06 12:36:07 +13:00
"""
Django settings for right_tree project.
Generated by 'django-admin startproject' using Django 3.2.8.
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
2021-10-06 12:36:07 +13:00
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
2021-11-16 17:30:40 +13:00
BASE_URL = os.getenv("BASE_URL", "localhost:8000")
2021-10-06 12:36:07 +13:00
# 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!
2021-11-16 17:30:40 +13:00
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", 'django-insecure-5t05qc2&14xuot4lgs#z0ll9(nn-=3-8yks!u(5ce704t&m_*q')
2021-10-06 12:36:07 +13:00
# SECURITY WARNING: don't run with debug turned on in production!
2021-11-16 17:30:40 +13:00
DEBUG = os.getenv('DJANGO_DEBUG_MODE', '') != 'False'
2021-10-06 12:36:07 +13:00
2023-02-08 14:24:48 +13:00
# os.getenv("ALLOWED_HOSTS", "").split(","),
ALLOWED_HOSTS = [BASE_URL, "localhost"]
2021-10-06 12:36:07 +13:00
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
2021-10-15 14:31:52 +13:00
'django.contrib.gis',
'rest_framework',
2021-10-07 10:17:32 +13:00
'corsheaders',
'right_tree.api',
2021-10-06 12:36:07 +13:00
]
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',
2021-10-07 10:17:32 +13:00
'corsheaders.middleware.CorsMiddleware',
2021-10-06 12:36:07 +13:00
]
ROOT_URLCONF = 'right_tree.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 = 'right_tree.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
db = {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': os.getenv("DATABASE_NAME", "righttree"),
'USER': os.getenv("DATABASE_USER", "righttree"),
'PASSWORD': os.getenv("DATABASE_PASSWORD", "righttree"),
'HOST': os.getenv("DATABASE_HOST", "postgres"),
'PORT': int(os.getenv("DATABASE_PORT", 5432)),
}
2021-10-06 12:36:07 +13:00
DATABASES = {
'default': db,
'linz': {
**db,
'OPTIONS': {
'options': '-c search_path=linz'
},
2021-10-06 12:36:07 +13:00
}
}
# 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 = 'Pacific/Auckland'
2021-10-06 12:36:07 +13:00
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
2021-11-16 17:30:40 +13:00
STATIC_URL = '/staticfiles/'
PROJECT_DIR = Path(os.path.abspath(__file__)).parent
STATIC_ROOT = PROJECT_DIR / 'staticfiles'
MEDIA_ROOT = PROJECT_DIR / 'media'
2021-10-06 12:36:07 +13:00
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
2021-10-07 10:17:32 +13:00
CORS_ALLOW_HEADERS = [
'access-control-allow-origin'
]
# Celery configuration
CELERY_TIMEZONE = TIME_ZONE
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL", "redis://redis:6379/0")