diff --git a/.gitignore b/.gitignore index cda67ad9..e78accd6 100644 --- a/.gitignore +++ b/.gitignore @@ -56,4 +56,4 @@ Thumbs.db Desktop.ini # Project settings -./site/ +/site/ diff --git a/src/manage.py b/src/manage.py index 7635b807..2db9bde1 100755 --- a/src/manage.py +++ b/src/manage.py @@ -1,7 +1,15 @@ #!/usr/bin/env python +from os.path import dirname, join, exists import os import sys +import environ + +env = environ.Env() +env_file = join(dirname(__file__), '{{ project_name }}/settings/' 'local.env') +if exists(env_file): + environ.Env.read_env(str(env_file)) + if __name__ == "__main__": # CHANGED manage.py will use development settings by # default. Change the DJANGO_SETTINGS_MODULE environment variable diff --git a/src/project_name/settings/base.py b/src/project_name/settings/base.py index 8472db25..9ae67301 100644 --- a/src/project_name/settings/base.py +++ b/src/project_name/settings/base.py @@ -7,8 +7,12 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/dev/ref/settings/ """ +from os.path import dirname, join + +from django.contrib import messages from django.core.urlresolvers import reverse_lazy -from os.path import dirname, join, exists +import environ + # Build paths inside the project like this: join(BASE_DIR, "directory") BASE_DIR = dirname(dirname(dirname(__file__))) @@ -42,15 +46,8 @@ ] # Use 12factor inspired environment variables or from a file -import environ env = environ.Env() -# Ideally move env file should be outside the git repo -# i.e. BASE_DIR.parent.parent -env_file = join(dirname(__file__), 'local.env') -if exists(env_file): - environ.Env.read_env(str(env_file)) - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ @@ -127,7 +124,6 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3' # For Bootstrap 3, change error alert to 'danger' -from django.contrib import messages MESSAGE_TAGS = { messages.ERROR: 'danger' } diff --git a/src/project_name/wsgi.py b/src/project_name/wsgi.py index a7187e0d..09bf0ead 100644 --- a/src/project_name/wsgi.py +++ b/src/project_name/wsgi.py @@ -6,14 +6,22 @@ For more information on this file, see https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/ """ +from os.path import dirname, join, exists import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings.production") +from django.conf import settings from django.core.wsgi import get_wsgi_application +import environ +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings.production") + +env = environ.Env() +env_file = join(dirname(__file__), 'settings/' 'local.env') +if exists(env_file): + environ.Env.read_env(str(env_file)) + application = get_wsgi_application() # Wrap werkzeug debugger if DEBUG is on -from django.conf import settings if settings.DEBUG: try: import django.views.debug