Skip to content

Commit

Permalink
continue reading instructions; split settings by environment
Browse files Browse the repository at this point in the history
  • Loading branch information
zackmdavis committed Nov 1, 2014
1 parent 17f0ca8 commit 66aa48c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ lib/
lib64
pyvenv.cfg

# collected static files for production-like environments
collectstatic/

# local copies of JavaScript libraries
static/libs/jquery-2.1.1.min.js
static/libs/underscore-min.js
Expand All @@ -30,5 +33,12 @@ logs/finetooth.log*
.coverage
htmlcov/

# the database
# the SQLite database
db.sqlite3



# sentinel file whose existence is used to decide whether it is the
# case that we're in a dev environment (and should use the
# corresponding Django settings)
.development
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ dj-database-url==0.3.0
dj-static==0.0.6
gunicorn==19.1.1
psycopg2==2.5.1
static==0.4
wsgiref==0.1.2
47 changes: 27 additions & 20 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

# TODO: review
# https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
IS_DEVELOPMENT = os.path.exists('.development')

# SECURITY WARNING: keep the secret key used in production secret!
# XXX TODO FIXME DANGER: the security warning on the previous line is
# big deal; if/when deploying this somewhere, change this and DO NOT
# keep the real value in a publicly-visible Git repo
SECRET_KEY = "fake_development_unsecret_key"
DEBUG = os.environ.get('DEBUG') or IS_DEVELOPMENT

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
if IS_DEVELOPMENT:
SECRET_KEY = os.environ.get('SECRET_KEY') or "fake_development_unsecret_key"
else:
SECRET_KEY = os.environ.get('SECRET_KEY')

TEMPLATE_DEBUG = True
TEMPLATE_DEBUG = DEBUG

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['*']

INSTALLED_APPS = (
'django.contrib.admin',
Expand All @@ -29,10 +26,12 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap3',
'debug_toolbar',
'core',
)

if DEBUG:
INSTALLED_APPS += ('debug_toolbar',)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
Expand All @@ -46,14 +45,18 @@

WSGI_APPLICATION = 'wsgi.application'

DATABASES = {
'default': {
# I <3 SQLite but maybe consider Postgres if/when deploying this
# somewhere
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join('db.sqlite3'),
if IS_DEVELOPMENT:
DATABASES = {
'default': {
# I <3 SQLite but maybe consider Postgres if/when deploying this
# somewhere
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join('db.sqlite3'),
}
}
}
else:
import dj_database_url
DATABASES = {'default': dj_database_url.config()}

AUTH_USER_MODEL = "core.FinetoothUser"

Expand Down Expand Up @@ -85,8 +88,12 @@
'core.context_processors.contextual_static_serving_context_processor'
)

STATIC_ROOT = 'staticfiles'

STATICFILES_DIRS = ('static',)
SERVE_STATIC_LIBS_LOCALLY = True

SERVE_STATIC_LIBS_LOCALLY = (os.environ.get('SERVE_STATIC_LIBS_LOCALLY')
or IS_DEVELOPMENT)

STATIC_URL = '/static/'

Expand Down
4 changes: 3 additions & 1 deletion wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
from dj_static import Cling

application = Cling(get_wsgi_application())

0 comments on commit 66aa48c

Please sign in to comment.