heroku deployment

master
Matt Huntington 5 years ago
parent 3887722325
commit 7ef7cdffa8

@ -0,0 +1 @@
web: gunicorn django_rest_api.wsgi

@ -0,0 +1,10 @@
asgiref==3.3.1
dj-database-url==0.5.0
Django==3.1.7
django-cors-headers==3.7.0
djangorestframework==3.12.4
gunicorn==20.1.0
psycopg2-binary==2.8.6
pytz==2021.1
sqlparse==0.4.1
whitenoise==5.2.0

@ -11,9 +11,11 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
""" """
from pathlib import Path from pathlib import Path
import dj_database_url
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
@ -25,7 +27,7 @@ SECRET_KEY = 'kwuq4$3jeof1(0!k7)+1@40t5s3pe5uo2-amnsl50rsrhwncs0'
# 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 = ['localhost', 'shrouded-depths-07664.herokuapp.com']
# Application definition # Application definition
@ -44,6 +46,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [ MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware', 'corsheaders.middleware.CorsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
@ -53,7 +56,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
] ]
CORS_ALLOW_ALL_ORIGINS = True CORS_ALLOW_ALL_ORIGINS = True
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
ROOT_URLCONF = 'timer_backend.urls' ROOT_URLCONF = 'timer_backend.urls'
TEMPLATES = [ TEMPLATES = [
@ -88,6 +91,9 @@ DATABASES = {
} }
} }
db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES['default'].update(db_from_env)
# Password validation # Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
@ -125,3 +131,4 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.1/howto/static-files/ # https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

Loading…
Cancel
Save