From 2af079f7aa8ae480afa7e3a122b9186935274c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20C=2E=20Barrionuevo=20da=20Luz?= Date: Mon, 9 Jan 2017 15:35:13 -0300 Subject: [PATCH 01/17] load .env file if DJANGO_READ_DOT_ENV_FILE is True --- .../config/settings/common.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/common.py b/{{cookiecutter.project_slug}}/config/settings/common.py index c0c86b397..34ff52d96 100644 --- a/{{cookiecutter.project_slug}}/config/settings/common.py +++ b/{{cookiecutter.project_slug}}/config/settings/common.py @@ -16,7 +16,21 @@ ROOT_DIR = environ.Path(__file__) - 3 # ({{ cookiecutter.project_slug }}/config APPS_DIR = ROOT_DIR.path('{{ cookiecutter.project_slug }}') env = environ.Env() -env.read_env() + +# Load operating system environment variables and then prepare to use them +env = environ.Env() + +# .env file, should load only in development environment +READ_DOT_ENV_FILE = env('DJANGO_READ_DOT_ENV_FILE', default=False) + +if READ_DOT_ENV_FILE: + # Operating System Environment variables have precende over variables defined in the .env file, + # that is to say variables from the .env files will only be used if not defined + # as environment variables. + env_file = str(ROOT_DIR.path('.env')) + print('Loading : {}'.format(env_file)) + env.read_env(env_file) + print('The .env file has been loaded. See common.py for more information') # APP CONFIGURATION # ------------------------------------------------------------------------------ From 06603dda17a500ba8a63b1184168e0712c43dc7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20C=2E=20Barrionuevo=20da=20Luz?= Date: Mon, 9 Jan 2017 15:39:27 -0300 Subject: [PATCH 02/17] fix W291 trailing whitespace on common.py --- {{cookiecutter.project_slug}}/config/settings/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/common.py b/{{cookiecutter.project_slug}}/config/settings/common.py index 34ff52d96..5afa7d993 100644 --- a/{{cookiecutter.project_slug}}/config/settings/common.py +++ b/{{cookiecutter.project_slug}}/config/settings/common.py @@ -24,7 +24,7 @@ env = environ.Env() READ_DOT_ENV_FILE = env('DJANGO_READ_DOT_ENV_FILE', default=False) if READ_DOT_ENV_FILE: - # Operating System Environment variables have precende over variables defined in the .env file, + # Operating System Environment variables have precende over variables defined in the .env file, # that is to say variables from the .env files will only be used if not defined # as environment variables. env_file = str(ROOT_DIR.path('.env')) From b0c771b6457a1c2e1983e78afd27b15193ee5f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20C=2E=20Barrionuevo=20da=20Luz?= Date: Mon, 9 Jan 2017 15:53:30 -0300 Subject: [PATCH 03/17] include DJANGO_READ_DOT_ENV_FILE on env.example --- {{cookiecutter.project_slug}}/env.example | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/env.example b/{{cookiecutter.project_slug}}/env.example index 66a3570d7..138b75fd9 100644 --- a/{{cookiecutter.project_slug}}/env.example +++ b/{{cookiecutter.project_slug}}/env.example @@ -4,6 +4,7 @@ POSTGRES_PASSWORD=mysecretpass POSTGRES_USER=postgresuser # General settings +# DJANGO_READ_DOT_ENV_FILE=True DJANGO_ADMIN_URL= DJANGO_SETTINGS_MODULE=config.settings.production DJANGO_SECRET_KEY=CHANGEME!!! From 10fa9065998346176ec1bb9eedf20a8a4b50105f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20C=2E=20Barrionuevo=20da=20Luz?= Date: Mon, 9 Jan 2017 16:02:53 -0300 Subject: [PATCH 04/17] add DJANGO_READ_DOT_ENV_FILE to settings docs --- docs/settings.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/settings.rst b/docs/settings.rst index eb6e92a45..893a47e90 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -3,7 +3,14 @@ Settings This project relies extensively on environment settings which **will not work with Apache/mod_wsgi setups**. It has been deployed successfully with both Gunicorn/Nginx and even uWSGI/Nginx. -For configuration purposes, the following table maps environment variables to their Django setting: +For configuration purposes, the following table maps environment variables to their Django setting and project settings: + + +======================================= =========================== ============================================== ====================================================================== +Environment Variable Django Setting Development Default Production Default +======================================= =========================== ============================================== ====================================================================== +DJANGO_READ_DOT_ENV_FILE READ_DOT_ENV_FILE False False +======================================= =========================== ============================================== ====================================================================== ======================================= =========================== ============================================== ====================================================================== From 12a8875dce4d7848eed116eee2b3b8b44e720e79 Mon Sep 17 00:00:00 2001 From: statwonk Date: Mon, 16 Jan 2017 21:18:07 -0600 Subject: [PATCH 05/17] Two Scoops 1.8 on p. 56 indicates base.txt is preferred for consistency --- .../config/settings/{common.py => base.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {{cookiecutter.project_slug}}/config/settings/{common.py => base.py} (100%) diff --git a/{{cookiecutter.project_slug}}/config/settings/common.py b/{{cookiecutter.project_slug}}/config/settings/base.py similarity index 100% rename from {{cookiecutter.project_slug}}/config/settings/common.py rename to {{cookiecutter.project_slug}}/config/settings/base.py From 62d86877e40f3ca9ff03d7423635634c23570ced Mon Sep 17 00:00:00 2001 From: statwonk Date: Mon, 16 Jan 2017 21:38:52 -0600 Subject: [PATCH 06/17] Missed a few references to the renamed settings file. This brings them inline. --- {{cookiecutter.project_slug}}/config/settings/local.py | 2 +- {{cookiecutter.project_slug}}/config/settings/production.py | 2 +- {{cookiecutter.project_slug}}/config/settings/test.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py index c72d3af11..969694bc9 100644 --- a/{{cookiecutter.project_slug}}/config/settings/local.py +++ b/{{cookiecutter.project_slug}}/config/settings/local.py @@ -14,7 +14,7 @@ Local settings import socket import os -from .common import * # noqa +from .base import * # noqa # DEBUG # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index c1fccc95b..94f781916 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -20,7 +20,7 @@ from django.utils import six import logging {% endif %} -from .common import * # noqa +from .base import * # noqa # SECRET CONFIGURATION # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/config/settings/test.py b/{{cookiecutter.project_slug}}/config/settings/test.py index 6d07eb50c..b1a43cd64 100644 --- a/{{cookiecutter.project_slug}}/config/settings/test.py +++ b/{{cookiecutter.project_slug}}/config/settings/test.py @@ -5,7 +5,7 @@ Test settings - Used to run tests fast on the continuous integration server and locally ''' -from .common import * # noqa +from .base import * # noqa # DEBUG From 83900ddfd39818411868ec9d2469ae0151c73baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20C=2E=20Barrionuevo=20da=20Luz?= Date: Fri, 3 Feb 2017 14:12:52 -0300 Subject: [PATCH 07/17] fix typo --- {{cookiecutter.project_slug}}/config/settings/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/common.py b/{{cookiecutter.project_slug}}/config/settings/common.py index 5afa7d993..60ca7e6d3 100644 --- a/{{cookiecutter.project_slug}}/config/settings/common.py +++ b/{{cookiecutter.project_slug}}/config/settings/common.py @@ -24,7 +24,7 @@ env = environ.Env() READ_DOT_ENV_FILE = env('DJANGO_READ_DOT_ENV_FILE', default=False) if READ_DOT_ENV_FILE: - # Operating System Environment variables have precende over variables defined in the .env file, + # Operating System Environment variables have precedence over variables defined in the .env file, # that is to say variables from the .env files will only be used if not defined # as environment variables. env_file = str(ROOT_DIR.path('.env')) From 5b75a9ccf2a1269db7915e1c0dbf5156d13adbed Mon Sep 17 00:00:00 2001 From: Matt Braymer-Hayes Date: Fri, 10 Feb 2017 00:21:04 -0800 Subject: [PATCH 08/17] 1029: Fix typo in Docker deployment docs (#1030) * #1029 Replace "wan't" with "want" * #1029 Add self to CONTRIBUTORS.rst --- CONTRIBUTORS.rst | 2 ++ docs/deployment-with-docker.rst | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 414d2a33b..7163cec14 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -107,6 +107,7 @@ Listed in alphabetical order. Lyla Fischer Martin Blech Mathijs Hoogland `@MathijsHoogland`_ + Matt Braymer-Hayes `@mattayes`_ @mattayes Matt Linares Matt Menzenski `@menzenski`_ Matt Warren `@mfwarren`_ @@ -193,6 +194,7 @@ Listed in alphabetical order. .. _@knitatoms: https://github.com/knitatoms .. _@krzysztofzuraw: https://github.com/krzysztofzuraw .. _@MathijsHoogland: https://github.com/MathijsHoogland +.. _@mattayes: https://github.com/mattayes .. _@menzenski: https://github.com/menzenski .. _@mfwarren: https://github.com/mfwarren .. _@mimischi: https://github.com/mimischi diff --git a/docs/deployment-with-docker.rst b/docs/deployment-with-docker.rst index 03aefd486..ac266993c 100644 --- a/docs/deployment-with-docker.rst +++ b/docs/deployment-with-docker.rst @@ -143,7 +143,7 @@ If you have errors, you can always check your stack with `docker-compose`. Switc Supervisor Example ------------------- -Once you are ready with your initial setup, you wan't to make sure that your application is run by a process manager to +Once you are ready with your initial setup, you want to make sure that your application is run by a process manager to survive reboots and auto restarts in case of an error. You can use the process manager you are most familiar with. All it needs to do is to run `docker-compose up` in your projects root directory. From d4f6f0b99c41fb06cfc3d41b49396e449bea7eae Mon Sep 17 00:00:00 2001 From: "Nikita P. Shupeyko" Date: Fri, 10 Feb 2017 14:33:29 +0300 Subject: [PATCH 09/17] Fix Docker test PyCharm Run Configurations settings file Switch from env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" to env name="DJANGO_SETTINGS_MODULE" value="config.settings.test" --- .../.idea/runConfigurations/Docker__tests___all.xml | 2 +- .../.idea/runConfigurations/Docker__tests___class__TestUser.xml | 2 +- .../runConfigurations/Docker__tests___file__test_models.xml | 2 +- .../.idea/runConfigurations/Docker__tests___module__users.xml | 2 +- .../Docker__tests___specific__test_get_absolute_url.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___all.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___all.xml index 7ede8bfb5..02fba0797 100644 --- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___all.xml +++ b/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___all.xml @@ -4,7 +4,7 @@