From 8222b4d5713fe67b6058280a6e252316754e38e7 Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells Date: Sat, 19 Aug 2017 10:16:51 -0400 Subject: [PATCH] Break out Django settings to separate files. --- babyblotter/settings/__init__.py | 0 babyblotter/{settings.py => settings/base.py} | 50 +++++++++---------- babyblotter/settings/development.py | 19 +++++++ 3 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 babyblotter/settings/__init__.py rename babyblotter/{settings.py => settings/base.py} (76%) create mode 100644 babyblotter/settings/development.py diff --git a/babyblotter/settings/__init__.py b/babyblotter/settings/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/babyblotter/settings.py b/babyblotter/settings/base.py similarity index 76% rename from babyblotter/settings.py rename to babyblotter/settings/base.py index 4c1af7a9..100bf312 100644 --- a/babyblotter/settings.py +++ b/babyblotter/settings/base.py @@ -1,22 +1,17 @@ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +BASE_DIR = os.path.dirname( + os.path.dirname( + os.path.dirname( + os.path.abspath(__file__) + ) + ) +) -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '(z4ha%^_=7#jco0wmna_#0jvyyt!03#f7l_y%@1x(a2xj$nrx%' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] - - -# Application definition +# Applications +# https://docs.djangoproject.com/en/1.11/ref/applications/ INSTALLED_APPS = [ 'api', @@ -35,6 +30,9 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', ] +# Middleware +# https://docs.djangoproject.com/en/1.11/ref/middleware/ + MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -45,8 +43,16 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] + +# URL dispatcher +# https://docs.djangoproject.com/en/1.11/topics/http/urls/ + ROOT_URLCONF = 'babyblotter.urls' + +# Templates +# https://docs.djangoproject.com/en/1.11/ref/templates/upgrading/#the-templates-settings + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', @@ -63,20 +69,13 @@ TEMPLATES = [ }, ] + +# WGSI +# https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ + WSGI_APPLICATION = 'babyblotter.wsgi.application' -# Database -# https://docs.djangoproject.com/en/1.11/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} - - # Authentication # https://docs.djangoproject.com/en/1.11/topics/auth/default/ @@ -115,6 +114,7 @@ STATICFILES_DIRS = [ # Django Rest Framework # http://www.django-rest-framework.org/# + REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'api.permissions.BabyBlotterDjangoModelPermissions' diff --git a/babyblotter/settings/development.py b/babyblotter/settings/development.py new file mode 100644 index 00000000..2ec1c2dc --- /dev/null +++ b/babyblotter/settings/development.py @@ -0,0 +1,19 @@ +from .base import * + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ + +SECRET_KEY = '(z4ha%^_=7#jco0wmna_#0jvyyt!03#f7l_y%@1x(a2xj$nrx%' +DEBUG = True +ALLOWED_HOSTS = ['*'] + + +# Database +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +}