From 56e0899565294729100459ea7dbe360b02f6b615 Mon Sep 17 00:00:00 2001 From: Mirco Grillo Date: Fri, 2 Oct 2020 12:26:18 +0200 Subject: [PATCH 1/2] Split Django settings - Split django settings into base, dev, test and prod --- .gitignore | 5 ++++- get_a_doc/settings/__init__.py | 0 get_a_doc/{settings.py => settings/base.py} | 15 +-------------- get_a_doc/settings/dev.py | 12 ++++++++++++ get_a_doc/settings/prod.py | 17 +++++++++++++++++ get_a_doc/settings/test.py | 1 + manage.py | 4 +++- 7 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 get_a_doc/settings/__init__.py rename get_a_doc/{settings.py => settings/base.py} (92%) create mode 100644 get_a_doc/settings/dev.py create mode 100644 get_a_doc/settings/prod.py create mode 100644 get_a_doc/settings/test.py diff --git a/.gitignore b/.gitignore index add4942..5d8405b 100644 --- a/.gitignore +++ b/.gitignore @@ -123,4 +123,7 @@ dmypy.json # End of https://www.gitignore.io/api/django # vs code files -.vscode \ No newline at end of file +.vscode +bin +libs +pyvenv.cfg \ No newline at end of file diff --git a/get_a_doc/settings/__init__.py b/get_a_doc/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/get_a_doc/settings.py b/get_a_doc/settings/base.py similarity index 92% rename from get_a_doc/settings.py rename to get_a_doc/settings/base.py index f1d1a38..97d0158 100644 --- a/get_a_doc/settings.py +++ b/get_a_doc/settings/base.py @@ -23,9 +23,7 @@ SECRET_KEY = '0&+ddh#txdwpps86wp57f9=_pynv#lug5no3!z2)qmd%v7%va)' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] +DEBUG = False # Application definition @@ -75,17 +73,6 @@ WSGI_APPLICATION = 'get_a_doc.wsgi.application' -# Database -# https://docs.djangoproject.com/en/3.0/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} - - # Password validation # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators diff --git a/get_a_doc/settings/dev.py b/get_a_doc/settings/dev.py new file mode 100644 index 0000000..5405902 --- /dev/null +++ b/get_a_doc/settings/dev.py @@ -0,0 +1,12 @@ +from .base import * # noqa + +DEBUG = True + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # noqa + } +} + +ALLOWED_HOST = ['*'] diff --git a/get_a_doc/settings/prod.py b/get_a_doc/settings/prod.py new file mode 100644 index 0000000..847eb3d --- /dev/null +++ b/get_a_doc/settings/prod.py @@ -0,0 +1,17 @@ +from .base import * # noqa + +# Database +# https://docs.djangoproject.com/en/3.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresq', + 'NAME': '', + 'PORT': 5432, + 'HOST': '127.0.0.1', + 'PASSWORD': '', + 'USER': '', + } +} + +ALLOWED_HOST = ['your_domains'] diff --git a/get_a_doc/settings/test.py b/get_a_doc/settings/test.py new file mode 100644 index 0000000..894333e --- /dev/null +++ b/get_a_doc/settings/test.py @@ -0,0 +1 @@ +from .dev import * # noqa diff --git a/manage.py b/manage.py index 272d202..fe689bd 100644 --- a/manage.py +++ b/manage.py @@ -5,7 +5,9 @@ def main(): - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'get_a_doc.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', + os.environ.get('DJANGO_SETTINGS_MODULE', + 'get_a_doc.settings.dev')) try: from django.core.management import execute_from_command_line except ImportError as exc: From 5eff6bc22595179e49ff6c2624a6906f97e77b0f Mon Sep 17 00:00:00 2001 From: Mirco Grillo Date: Mon, 12 Oct 2020 18:23:57 +0200 Subject: [PATCH 2/2] Update gitignore to ignore .idea directory --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5d8405b..1b798ac 100644 --- a/.gitignore +++ b/.gitignore @@ -126,4 +126,6 @@ dmypy.json .vscode bin libs -pyvenv.cfg \ No newline at end of file +pyvenv.cfg + +.idea \ No newline at end of file