Browse Source

Add support for dotenv configuration file

pull/103/head
Clemens Wolff 5 years ago
parent
commit
617db50c8c
2 changed files with 19 additions and 17 deletions
  1. 35
      app/app/settings.py
  2. 1
      requirements.txt

35
app/app/settings.py

@ -1,38 +1,39 @@
"""
Django settings for app project.
Generated by 'django-admin startproject' using Django 2.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
Any setting that is configured via an environment variable may
also be set in a `.env` file in the project base directory.
"""
import os
import django_heroku
import dj_database_url
from environs import Env
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
env = Env()
env.read_env(BASE_DIR, recurse=False)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get(
'SECRET_KEY',
'v8sk33sy82!uw3ty=!jjv5vp7=s2phrzw(m(hrn^f7e_#1h2al')
SECRET_KEY = env('SECRET_KEY',
'v8sk33sy82!uw3ty=!jjv5vp7=s2phrzw(m(hrn^f7e_#1h2al')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
if os.environ.get('DEBUG') == 'False':
DEBUG = False
# DEBUG = bool(os.environ.get('DEBUG', False))
# DEBUG = os.environ.get('DEBUG') == 'TRUE'
DEBUG = env.bool('DEBUG', True)
# ALLOWED_HOSTS = []
@ -104,12 +105,12 @@ AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
]
SOCIAL_AUTH_GITHUB_KEY = os.getenv('OAUTH_GITHUB_KEY')
SOCIAL_AUTH_GITHUB_SECRET = os.getenv('OAUTH_GITHUB_SECRET')
SOCIAL_AUTH_GITHUB_KEY = env('OAUTH_GITHUB_KEY', None)
SOCIAL_AUTH_GITHUB_SECRET = env('OAUTH_GITHUB_SECRET', None)
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY = os.getenv('OAUTH_AAD_KEY')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET = os.getenv('OAUTH_AAD_SECRET')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID = os.getenv('OAUTH_AAD_TENANT')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY = env('OAUTH_AAD_KEY', None)
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET = env('OAUTH_AAD_SECRET', None)
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID = env('OAUTH_AAD_TENANT', None)
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
@ -189,9 +190,9 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# on the import phase
IMPORT_BATCH_SIZE = 500
GOOGLE_TRACKING_ID = os.getenv('GOOGLE_TRACKING_ID', 'UA-125643874-2')
GOOGLE_TRACKING_ID = env('GOOGLE_TRACKING_ID', 'UA-125643874-2')
AZURE_APPINSIGHTS_IKEY = os.getenv('AZURE_APPINSIGHTS_IKEY')
AZURE_APPINSIGHTS_IKEY = env('AZURE_APPINSIGHTS_IKEY', None)
APPLICATION_INSIGHTS = {
'ikey': AZURE_APPINSIGHTS_IKEY if AZURE_APPINSIGHTS_IKEY else None,
}

1
requirements.txt

@ -6,6 +6,7 @@ django-heroku==0.3.1
django-widget-tweaks==1.4.2
djangorestframework==3.8.2
djangorestframework-filters==0.10.2
environs==4.1.0
Faker==0.8.8
flake8==3.6.0
gunicorn==19.9.0

Loading…
Cancel
Save