-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Postgresql config in production.
Added Postgresql config if is present ENV => DATABASE_URL. Added migrations. Fixed path sqlite. Added MAILTRAP.
- Loading branch information
1 parent
ef8cd3f
commit cc3e0f1
Showing
5 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn superlists.wsgi --log-file - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# !/usr/bin/env bash | ||
# File path should be ./bin/post_compile | ||
# (.sh extension added in Gist just to enable shell syntax highlighting. | ||
# https://discussion.heroku.com/t/django-automaticlly-run-syncdb-and-migrations-after-heroku-deploy-with-a-buildpack-or-otherwise/466/7 | ||
|
||
echo "=> Performing database migrations..." | ||
python manage.py migrate | ||
|
||
echo "=> Generating static files..." | ||
python manage.py collectstatic --noinput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
django==1.10.4 | ||
gunicorn==19.6.0 | ||
dj-database-url==0.4.1 | ||
psycopg2>=2.6.1 | ||
whitenoise==3.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
""" | ||
|
||
import os | ||
import dj_database_url | ||
|
||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
@@ -25,7 +26,7 @@ | |
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = [] | ||
ALLOWED_HOSTS = ['localhost', 'testing-example.herokuapp.com'] | ||
|
||
|
||
# Application definition | ||
|
@@ -84,11 +85,22 @@ | |
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(BASE_DIR, '../database/db.sqlite3'), | ||
'NAME': os.path.join(BASE_DIR, './database/db.sqlite3'), | ||
} | ||
} | ||
|
||
|
||
if os.getenv('DATABASE_URL', '') != '': | ||
# Update database configuration with $DATABASE_URL. | ||
db_from_env = dj_database_url.config() | ||
DATABASES['default'].update(db_from_env) | ||
|
||
# Simplified static file serving. | ||
# https://warehouse.python.org/project/whitenoise/ | ||
|
||
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' | ||
|
||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators | ||
|
||
|
@@ -145,8 +157,12 @@ | |
'root': {'level': 'INFO'}, | ||
} | ||
|
||
EMAIL_HOST = 'smtp.gmail.com' | ||
EMAIL_HOST_USER = '[email protected]' | ||
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASSWORD') | ||
EMAIL_USE_TLS = True | ||
if os.getenv('MAILTRAP_ENABLED', '') != '': | ||
EMAIL_HOST = 'mailtrap.io' | ||
EMAIL_HOST_USER = os.getenv('MAILTRAP_USER', '') | ||
EMAIL_HOST_PASSWORD = os.getenv('MAILTRAP_PASSWORD', '') | ||
EMAIL_PORT = '2525' | ||
|
||
else: | ||
# It writes e-mails to standard out instead of sending them | ||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters