website/website/settings.py

136 lines
3.2 KiB
Python
Raw Normal View History

2022-06-09 08:36:29 +01:00
import os
2022-06-09 08:51:47 +01:00
import environ
2022-06-09 08:36:29 +01:00
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2022-06-09 08:51:47 +01:00
env = environ.Env(
DEBUG=(bool, False),
BASE_HOSTNAME=(str, "example.com")
)
2022-06-09 08:36:29 +01:00
2022-06-09 08:51:47 +01:00
# Read local secrets
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))
2022-06-09 08:36:29 +01:00
2022-06-09 08:51:47 +01:00
DEBUG = env('DEBUG')
2022-06-09 08:36:29 +01:00
2022-06-09 08:51:47 +01:00
SECRET_KEY = env('SECRET_KEY')
2022-06-09 08:36:29 +01:00
ALLOWED_HOSTS = ["*"]
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
# Application definition
INSTALLED_APPS = [
"website.home",
"website.search",
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
"wagtail.snippets",
"wagtail.documents",
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail",
"modelcluster",
"taggit",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
2022-06-09 09:03:00 +01:00
"whitenoise.runserver_nostatic",
2022-06-09 08:36:29 +01:00
"django.contrib.staticfiles",
]
MIDDLEWARE = [
2022-06-09 09:03:00 +01:00
"django.middleware.security.SecurityMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
2022-06-09 08:36:29 +01:00
"django.middleware.common.CommonMiddleware",
2022-06-09 09:03:00 +01:00
"django.contrib.sessions.middleware.SessionMiddleware",
2022-06-09 08:36:29 +01:00
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
]
ROOT_URLCONF = "website.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
os.path.join(BASE_DIR, "templates"),
],
"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 = "website.wsgi.application"
DATABASES = {
2022-06-09 08:51:47 +01:00
'default': env.db(default=f"sqlite:///{BASE_DIR}/db.sqlite3")
2022-06-09 08:36:29 +01:00
}
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = "en-gb"
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
2022-06-09 09:03:00 +01:00
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
2022-06-09 08:36:29 +01:00
STATIC_ROOT = os.path.join(BASE_DIR, "collected-static")
STATIC_URL = "/static/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = "/media/"
# Wagtail settings
WAGTAIL_SITE_NAME = "website"
# Search
# https://docs.wagtail.org/en/stable/topics/search/backends.html
WAGTAILSEARCH_BACKENDS = {
"default": {
"BACKEND": "wagtail.search.backends.database",
}
}
2022-06-09 08:51:47 +01:00
BASE_HOSTNAME = env('BASE_HOSTNAME')
WAGTAILADMIN_BASE_URL = f"https://{BASE_HOSTNAME}"