Update settings to use pathlib

This commit is contained in:
Jake Howard 2022-06-10 09:16:13 +01:00
parent c1fdd81f86
commit b195ae2a62
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -1,7 +1,7 @@
import os
from pathlib import Path
import environ
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = Path(__file__).parent.parent
env = environ.Env(
DEBUG=(bool, False),
@ -9,7 +9,7 @@ env = environ.Env(
)
# Read local secrets
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))
environ.Env.read_env(BASE_DIR / '.env')
DEBUG = env('DEBUG')
@ -63,7 +63,7 @@ TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
os.path.join(BASE_DIR, "templates"),
BASE_DIR / "templates",
],
"APP_DIRS": True,
"OPTIONS": {
@ -107,15 +107,15 @@ STATICFILES_FINDERS = [
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static", "build"),
BASE_DIR / "static" / "build",
]
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STATIC_ROOT = os.path.join(BASE_DIR, "collected-static")
STATIC_ROOT = BASE_DIR / "collected-static"
STATIC_URL = "/static/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_ROOT = BASE_DIR / "media"
MEDIA_URL = "/media/"