Skip to content

Commit

Permalink
Added django-environ without Path related stuff. SECRET_KEY is now in…
Browse files Browse the repository at this point in the history
… an env file
  • Loading branch information
arocks committed Sep 12, 2014
1 parent 56de630 commit b7367d8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ build
# Logs:
*.log

# Environment variables
*.env

# Django stuff:
*.mo
*.pot
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Django==1.7
django-braces==1.4.0
django-environ==0.3.0
16 changes: 11 additions & 5 deletions src/project_name/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]

# Use 12factor inspired environment variables or from a file
import environ
env = environ.Env()
env_file = os.path.join(BASE_DIR, '{{ project_name }}', 'local.env')
if os.path.isfile(env_file):
environ.Env.read_env(env_file)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "{{ secret_key }}"
# Raises ImproperlyConfigured exception if SECRET_KEY not in os.environ
SECRET_KEY = env('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down Expand Up @@ -58,10 +65,9 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
# Raises ImproperlyConfigured exception if DATABASE_URL not in
# os.environ
'default': env.db(),
}

# Internationalization
Expand Down

0 comments on commit b7367d8

Please sign in to comment.