From 9302cccd58c7e2069863e9022457be33d8791815 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Tue, 23 Feb 2021 00:34:27 +0000 Subject: [PATCH] Swithc to pathlib in settings --- PyRIGS/settings.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index af823a99..189f3665 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -9,23 +9,18 @@ https://docs.djangoproject.com/en/1.7/ref/settings/ """ import datetime -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -import os +from pathlib import Path import secrets import sentry_sdk from sentry_sdk.integrations.django import DjangoIntegration from envparse import env -BASE_DIR = os.path.dirname(os.path.dirname(__file__)) - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve(strict=True).parent.parent # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = env('SECRET_KEY', default='gxhy(a#5mhp289_=6xx$7jh=eh$ymxg^ymc+di*0c*geiu3p_e') - - # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env('DEBUG', cast=bool, default=True) STAGING = env('STAGING', cast=bool, default=False) @@ -97,7 +92,7 @@ WSGI_APPLICATION = 'PyRIGS.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'NAME': str(BASE_DIR / 'db.sqlite3'), } } @@ -235,19 +230,19 @@ DATETIME_INPUT_FORMATS = ('%Y-%m-%dT%H:%M', '%Y-%m-%dT%H:%M:%S') # Static files (CSS, JavaScript, Images) STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, 'static/') +STATIC_ROOT = BASE_DIR / 'static/' STATIC_DIRS = [ - os.path.join(BASE_DIR, 'static/'), + BASE_DIR / 'static/', ] STATICFILES_DIRS = [ - os.path.join(BASE_DIR, 'pipeline/built_assets'), + BASE_DIR / 'pipeline/built_assets', ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ - os.path.join(BASE_DIR, 'templates') + BASE_DIR / 'templates' ], 'APP_DIRS': True, 'OPTIONS': {