diff --git a/.gitignore b/.gitignore index 9e1d89c..68b4bc5 100644 --- a/.gitignore +++ b/.gitignore @@ -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 @@ -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 diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..737b14a --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn wsgi --log-file - \ No newline at end of file diff --git a/dev_requirements.txt b/dev_requirements.txt new file mode 100644 index 0000000..b44730e --- /dev/null +++ b/dev_requirements.txt @@ -0,0 +1,7 @@ +bleach==1.4 +Django==1.7 +django-bootstrap3==4.11.0 +django-debug-toolbar==1.2.1 +Markdown==2.4.1 +jasmine==2.0.1 +factory_boy==2.4.1 diff --git a/requirements.txt b/requirements.txt index b44730e..2f7bd02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ bleach==1.4 Django==1.7 django-bootstrap3==4.11.0 -django-debug-toolbar==1.2.1 Markdown==2.4.1 -jasmine==2.0.1 -factory_boy==2.4.1 +dj-database-url==0.3.0 +dj-static==0.0.6 +gunicorn==19.1.1 +psycopg2==2.5.1 diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..02d9bbd --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.4.1 diff --git a/settings.py b/settings.py index e68977f..af2eeba 100644 --- a/settings.py +++ b/settings.py @@ -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', @@ -29,10 +26,12 @@ 'django.contrib.messages', 'django.contrib.staticfiles', 'bootstrap3', - 'debug_toolbar', 'core', ) +if DEBUG and IS_DEVELOPMENT: + INSTALLED_APPS += ('debug_toolbar',) + MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -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" @@ -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/' diff --git a/wsgi.py b/wsgi.py index ac5b730..ada7558 100644 --- a/wsgi.py +++ b/wsgi.py @@ -8,7 +8,9 @@ """ import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Finetooth.settings") +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())