Add django-heroku config

This commit is contained in:
Gabriel Augendre 2019-03-02 16:49:58 +01:00
parent a010341d10
commit 3c3f9ee98b
3 changed files with 37 additions and 6 deletions

View file

@ -7,9 +7,9 @@ name = "pypi"
django = "*" django = "*"
gitpython = "*" gitpython = "*"
django-crispy-forms = "*" django-crispy-forms = "*"
dj-database-url = "*"
"psycopg2" = "*" "psycopg2" = "*"
gunicorn = "*" gunicorn = "*"
django-heroku = "*"
[dev-packages] [dev-packages]

18
Pipfile.lock generated
View file

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "8e4f8594bffd8bc27af35d8b7d41c9db598ec2715709e3e11060671d4bdb6a06" "sha256": "865aaeb0d93d5e877f331fdeeabff95e3ea61ac49c894a62024e039c847c0218"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@ -21,7 +21,6 @@
"sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163", "sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163",
"sha256:851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9" "sha256:851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9"
], ],
"index": "pypi",
"version": "==0.5.0" "version": "==0.5.0"
}, },
"django": { "django": {
@ -40,6 +39,14 @@
"index": "pypi", "index": "pypi",
"version": "==1.7.2" "version": "==1.7.2"
}, },
"django-heroku": {
"hashes": [
"sha256:2bc690aab89eedbe01311752320a9a12e7548e3b0ed102681acc5736a41a4762",
"sha256:6af4bc3ae4a9b55eaad6dbe5164918982d2762661aebc9f83d9fa49f6009514e"
],
"index": "pypi",
"version": "==0.3.1"
},
"gitdb2": { "gitdb2": {
"hashes": [ "hashes": [
"sha256:83361131a1836661a155172932a13c08bda2db3674e4caa32368aa6eb02f38c2", "sha256:83361131a1836661a155172932a13c08bda2db3674e4caa32368aa6eb02f38c2",
@ -112,6 +119,13 @@
"sha256:29a9ffa0497e7f2be94ca0ed1ca1aa3cd4cf25a1f6b4f5f87f74b46ed91d609a" "sha256:29a9ffa0497e7f2be94ca0ed1ca1aa3cd4cf25a1f6b4f5f87f74b46ed91d609a"
], ],
"version": "==2.0.5" "version": "==2.0.5"
},
"whitenoise": {
"hashes": [
"sha256:118ab3e5f815d380171b100b05b76de2a07612f422368a201a9ffdeefb2251c1",
"sha256:42133ddd5229eeb6a0c9899496bdbe56c292394bf8666da77deeb27454c0456a"
],
"version": "==4.1.2"
} }
}, },
"develop": {} "develop": {}

View file

@ -13,7 +13,7 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
import os import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import dj_database_url import django_heroku
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -27,7 +27,18 @@ SECRET_KEY = '(b_w%!e9u!3q=d-u!$g6ntpzh-=4mo$gs#96as+^179vp6stui'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = [] ALLOWED_HOSTS = [
'.herokuapp.com',
]
HOST = os.environ.get('HOST')
if HOST:
ALLOWED_HOSTS.append(HOST)
if DEBUG:
ALLOWED_HOSTS += [
'localhost'
]
# Application definition # Application definition
@ -79,7 +90,12 @@ WSGI_APPLICATION = 'friends_map.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {'default': dj_database_url.config(default=f'sqlite:///{BASE_DIR}/db.sqlite3', conn_max_age=600)} DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation # Password validation
@ -143,3 +159,4 @@ APP = {
CRISPY_TEMPLATE_PACK = 'bootstrap4' CRISPY_TEMPLATE_PACK = 'bootstrap4'
LOGOUT_REDIRECT_URL = '/' LOGOUT_REDIRECT_URL = '/'
django_heroku.settings(locals(), allowed_hosts=False, databases=not DEBUG)