|
| 1 | +""" |
| 2 | +Django settings for dashboard project. |
| 3 | +
|
| 4 | +Generated by 'django-admin startproject' using Django 4.2.1. |
| 5 | +
|
| 6 | +For more information on this file, see |
| 7 | +https://docs.djangoproject.com/en/4.2/topics/settings/ |
| 8 | +
|
| 9 | +For the full list of settings and their values, see |
| 10 | +https://docs.djangoproject.com/en/4.2/ref/settings/ |
| 11 | +""" |
| 12 | + |
| 13 | +from pathlib import Path |
| 14 | + |
| 15 | +import json |
| 16 | +import os |
| 17 | +import secrets |
| 18 | + |
| 19 | + |
| 20 | +# Build paths inside the project like this: BASE_DIR / 'subdir'. |
| 21 | +BASE_DIR = Path(__file__).resolve().parent.parent |
| 22 | + |
| 23 | + |
| 24 | +# Quick-start development settings - unsuitable for production |
| 25 | +# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ |
| 26 | + |
| 27 | +# SECURITY WARNING: keep the secret key used in production secret! |
| 28 | +SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', secrets.token_hex(32)) |
| 29 | + |
| 30 | +# SECURITY WARNING: don't run with debug turned on in production! |
| 31 | + |
| 32 | +DEBUG = os.environ.get('DJANGO_DEBUG', 'false') == 'true' |
| 33 | + |
| 34 | +ALLOWED_HOSTS = json.loads(os.environ.get('DJANGO_ALLOWED_HOSTS', '[]')) |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +# Application definition |
| 39 | + |
| 40 | +INSTALLED_APPS = [ |
| 41 | + "whitenoise.runserver_nostatic", |
| 42 | + "projects", |
| 43 | + "framework", |
| 44 | + "dashboard", |
| 45 | + "django.contrib.admin", |
| 46 | + "django.contrib.admindocs", |
| 47 | + "django.contrib.auth", |
| 48 | + "django.contrib.contenttypes", |
| 49 | + "django.contrib.sessions", |
| 50 | + "django.contrib.messages", |
| 51 | + "django.contrib.staticfiles", |
| 52 | +] |
| 53 | + |
| 54 | +MIDDLEWARE = [ |
| 55 | + "django.middleware.security.SecurityMiddleware", |
| 56 | + "django.contrib.sessions.middleware.SessionMiddleware", |
| 57 | + "whitenoise.middleware.WhiteNoiseMiddleware", |
| 58 | + "django.middleware.common.CommonMiddleware", |
| 59 | + "django.middleware.csrf.CsrfViewMiddleware", |
| 60 | + "django.contrib.auth.middleware.AuthenticationMiddleware", |
| 61 | + "django.contrib.messages.middleware.MessageMiddleware", |
| 62 | + "django.middleware.clickjacking.XFrameOptionsMiddleware", |
| 63 | + "django.contrib.admindocs.middleware.XViewMiddleware", |
| 64 | +] |
| 65 | + |
| 66 | +ROOT_URLCONF = "dashboard.urls" |
| 67 | + |
| 68 | +TEMPLATES = [ |
| 69 | + { |
| 70 | + "BACKEND": "django.template.backends.django.DjangoTemplates", |
| 71 | + "DIRS": [BASE_DIR / "templates"], |
| 72 | + "APP_DIRS": True, |
| 73 | + "OPTIONS": { |
| 74 | + "context_processors": [ |
| 75 | + "django.template.context_processors.debug", |
| 76 | + "django.template.context_processors.request", |
| 77 | + "django.contrib.auth.context_processors.auth", |
| 78 | + "django.contrib.messages.context_processors.messages", |
| 79 | + ], |
| 80 | + }, |
| 81 | + }, |
| 82 | +] |
| 83 | + |
| 84 | +WSGI_APPLICATION = "dashboard.wsgi.application" |
| 85 | + |
| 86 | + |
| 87 | +# Database |
| 88 | +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases |
| 89 | + |
| 90 | +DATABASES = { |
| 91 | + "default": { |
| 92 | + 'ENGINE': 'django.db.backends.postgresql', |
| 93 | + 'NAME': os.environ.get('POSTGRESQL_DB_NAME'), |
| 94 | + 'USER': os.environ.get('POSTGRESQL_DB_USERNAME'), |
| 95 | + 'PASSWORD': os.environ.get('POSTGRESQL_DB_PASSWORD'), |
| 96 | + 'HOST': os.environ.get('POSTGRESQL_DB_HOSTNAME'), |
| 97 | + 'PORT': os.environ.get('POSTGRESQL_DB_PORT'), |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | + |
| 102 | +# Password validation |
| 103 | +# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators |
| 104 | + |
| 105 | +AUTH_PASSWORD_VALIDATORS = [ |
| 106 | + { |
| 107 | + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", |
| 108 | + }, |
| 109 | + { |
| 110 | + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", |
| 111 | + }, |
| 112 | + { |
| 113 | + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", |
| 114 | + }, |
| 115 | + { |
| 116 | + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", |
| 117 | + }, |
| 118 | +] |
| 119 | + |
| 120 | + |
| 121 | +# Internationalization |
| 122 | +# https://docs.djangoproject.com/en/4.2/topics/i18n/ |
| 123 | + |
| 124 | +LANGUAGE_CODE = "en-gb" |
| 125 | + |
| 126 | +TIME_ZONE = "UTC" |
| 127 | + |
| 128 | +USE_I18N = True |
| 129 | + |
| 130 | +USE_TZ = True |
| 131 | + |
| 132 | + |
| 133 | +# Static files (CSS, JavaScript, Images) |
| 134 | +# https://docs.djangoproject.com/en/4.2/howto/static-files/ |
| 135 | + |
| 136 | +STATIC_URL = "static/" |
| 137 | +STATIC_ROOT = BASE_DIR / "staticfiles" |
| 138 | + |
| 139 | +# Default primary key field type |
| 140 | +# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field |
| 141 | + |
| 142 | +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" |
0 commit comments