Read configuration from environment
This commit is contained in:
parent
5f814b2a5a
commit
531b75c128
2 changed files with 13 additions and 52 deletions
|
@ -1,2 +1,3 @@
|
||||||
Django==4.0.5
|
Django==4.0.5
|
||||||
wagtail==3.0
|
wagtail==3.0
|
||||||
|
django-environ==0.8.1
|
||||||
|
|
|
@ -1,38 +1,25 @@
|
||||||
"""
|
|
||||||
Django settings for website project.
|
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 4.0.5.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/4.0/topics/settings/
|
|
||||||
|
|
||||||
For the full list of settings and their values, see
|
|
||||||
https://docs.djangoproject.com/en/4.0/ref/settings/
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
||||||
import os
|
import os
|
||||||
|
import environ
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
env = environ.Env(
|
||||||
|
DEBUG=(bool, False),
|
||||||
|
BASE_HOSTNAME=(str, "example.com")
|
||||||
|
)
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Read local secrets
|
||||||
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
DEBUG = env('DEBUG')
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
SECRET_KEY = env('SECRET_KEY')
|
||||||
SECRET_KEY = "django-insecure-_w9@x(3f5xaa+3n%!a#v7!i9!n4dh0%hn2nb9@c49=2r2664u*"
|
|
||||||
|
|
||||||
# SECURITY WARNING: define the correct hosts in production!
|
|
||||||
ALLOWED_HOSTS = ["*"]
|
ALLOWED_HOSTS = ["*"]
|
||||||
|
|
||||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
"website.home",
|
"website.home",
|
||||||
"website.search",
|
"website.search",
|
||||||
|
@ -91,35 +78,9 @@ TEMPLATES = [
|
||||||
WSGI_APPLICATION = "website.wsgi.application"
|
WSGI_APPLICATION = "website.wsgi.application"
|
||||||
|
|
||||||
|
|
||||||
# Database
|
|
||||||
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
|
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": {
|
'default': env.db(default=f"sqlite:///{BASE_DIR}/db.sqlite3")
|
||||||
"ENGINE": "django.db.backends.sqlite3",
|
|
||||||
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
|
||||||
# https://docs.djangoproject.com/en/4.0/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
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/4.0/topics/i18n/
|
# https://docs.djangoproject.com/en/4.0/topics/i18n/
|
||||||
|
@ -171,6 +132,5 @@ WAGTAILSEARCH_BACKENDS = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Base URL to use when referring to full URLs within the Wagtail admin backend -
|
BASE_HOSTNAME = env('BASE_HOSTNAME')
|
||||||
# e.g. in notification emails. Don't include '/admin' or a trailing slash
|
WAGTAILADMIN_BASE_URL = f"https://{BASE_HOSTNAME}"
|
||||||
WAGTAILADMIN_BASE_URL = "http://example.com"
|
|
||||||
|
|
Loading…
Reference in a new issue