135 lines
3.2 KiB
Python
135 lines
3.2 KiB
Python
import os
|
|
import environ
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
env = environ.Env(
|
|
DEBUG=(bool, False),
|
|
BASE_HOSTNAME=(str, "example.com")
|
|
)
|
|
|
|
# Read local secrets
|
|
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))
|
|
|
|
DEBUG = env('DEBUG')
|
|
|
|
SECRET_KEY = env('SECRET_KEY')
|
|
|
|
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",
|
|
"whitenoise.runserver_nostatic",
|
|
"django.contrib.staticfiles",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"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 = {
|
|
'default': env.db(default=f"sqlite:///{BASE_DIR}/db.sqlite3")
|
|
}
|
|
|
|
# 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"),
|
|
]
|
|
|
|
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
|
|
|
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",
|
|
}
|
|
}
|
|
|
|
BASE_HOSTNAME = env('BASE_HOSTNAME')
|
|
WAGTAILADMIN_BASE_URL = f"https://{BASE_HOSTNAME}"
|