From 34d659050ed6432a25a72127531032e07235dc3a Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 18 Dec 2020 14:09:11 -0500 Subject: [PATCH] Move settings into module and split out dev settings --- .gitignore | 2 ++ manage.py | 2 +- recmaint/settings/__init__.py | 0 recmaint/{settings.py => settings/base.py} | 27 +--------------------- recmaint/settings/dev.py | 20 ++++++++++++++++ recmaint/settings/prod_base.py | 3 +++ 6 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 .gitignore create mode 100644 recmaint/settings/__init__.py rename recmaint/{settings.py => settings/base.py} (81%) create mode 100644 recmaint/settings/dev.py create mode 100644 recmaint/settings/prod_base.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dbbb0d6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +/recmaint/settings/prod.py diff --git a/manage.py b/manage.py index d08bb83..56684bf 100755 --- a/manage.py +++ b/manage.py @@ -6,7 +6,7 @@ import sys def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'recmaint.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'recmaint.settings.dev') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/recmaint/settings/__init__.py b/recmaint/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/recmaint/settings.py b/recmaint/settings/base.py similarity index 81% rename from recmaint/settings.py rename to recmaint/settings/base.py index 1539950..d759902 100644 --- a/recmaint/settings.py +++ b/recmaint/settings/base.py @@ -14,17 +14,7 @@ import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'g&zqf68eks@z$ctb%3_5+retmt%_i0=)7-y$i^gvc6p#s1+*ng' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +BASE_DIR = Path(__file__).resolve().parent.parent.parent ALLOWED_HOSTS = [] @@ -73,17 +63,6 @@ TEMPLATES = [ WSGI_APPLICATION = 'recmaint.wsgi.application' -# Database -# https://docs.djangoproject.com/en/3.1/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', - } -} - - # Password validation # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators @@ -109,13 +88,9 @@ LOGIN_REDIRECT_URL = '/' # https://docs.djangoproject.com/en/3.1/topics/i18n/ LANGUAGE_CODE = 'en-us' - TIME_ZONE = 'America/New_York' - USE_I18N = False - USE_L10N = True - USE_TZ = True diff --git a/recmaint/settings/dev.py b/recmaint/settings/dev.py new file mode 100644 index 0000000..fe8fe13 --- /dev/null +++ b/recmaint/settings/dev.py @@ -0,0 +1,20 @@ +from .base import * + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'g&zqf68eks@z$ctb%3_5+retmt%_i0=)7-y$i^gvc6p#s1+*ng' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +# Database +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} diff --git a/recmaint/settings/prod_base.py b/recmaint/settings/prod_base.py new file mode 100644 index 0000000..42e5eac --- /dev/null +++ b/recmaint/settings/prod_base.py @@ -0,0 +1,3 @@ +from .base import * + +DEBUG = False