Skip to content

Commit

Permalink
Initial app and 12factor
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Pablo Santos committed Aug 17, 2015
1 parent a8e9b05 commit 159b99d
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL=
DEBUG=
SECRET_KEY=
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

.env
.env.test
Empty file.
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
"""
Django settings for automated_survey project.
Generated by 'django-admin startproject' using Django 1.8.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from .env import env

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

Expand All @@ -20,13 +9,15 @@
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'dsv%48rwt8g4t-(r)1k-k^3#md&kje&16bmj83_8%6$+g!m%(s'
SECRET_KEY = env('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# DEBUG = True

ALLOWED_HOSTS = []
# ALLOWED_HOSTS = []

DEBUG = env('DEBUG')
TEMPLATE_DEBUG = DEBUG

# Application definition

Expand Down Expand Up @@ -75,10 +66,7 @@
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
'default': env.db()
}


Expand All @@ -100,3 +88,4 @@
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
4 changes: 4 additions & 0 deletions automated_survey/settings/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import environ

root = environ.Path(__file__) - 3 # three folder back (/a/b/c/ - 3 = /)
env = environ.Env(DEBUG=(bool, False),) # set default values and casting
5 changes: 5 additions & 0 deletions automated_survey/settings/local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import environ

environ.Env.read_env('.env')

from .common import *
3 changes: 3 additions & 0 deletions automated_survey/settings/production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .common import *

DEBUG = False
5 changes: 5 additions & 0 deletions automated_survey/settings/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import environ

environ.Env.read_env('.env.test')

from .common import *
2 changes: 1 addition & 1 deletion automated_survey/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "automated_survey.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "automated_survey.settings.production")

application = get_wsgi_application()
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "automated_survey.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "automated_survey.settings.local")

from django.core.management import execute_from_command_line

Expand Down
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Django==1.8.3
django-environ==0.3.0
pbr==1.3.0
psycopg2==2.6.1
six==1.9.0
stevedore==1.6.0
wheel==0.24.0

0 comments on commit 159b99d

Please sign in to comment.