|
| 1 | +""" |
| 2 | +Django settings for oshc project. |
| 3 | +
|
| 4 | +For more information on this file, see |
| 5 | +https://docs.djangoproject.com/en/1.7/topics/settings/ |
| 6 | +
|
| 7 | +For the full list of settings and their values, see |
| 8 | +https://docs.djangoproject.com/en/1.7/ref/settings/ |
| 9 | +""" |
| 10 | + |
| 11 | +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
| 12 | +import os |
| 13 | +import dj_database_url |
| 14 | +from django.core.exceptions import ImproperlyConfigured |
| 15 | + |
| 16 | + |
| 17 | +def get_env_variable(var_name): |
| 18 | + """Get the environment variable or return exception""" |
| 19 | + try: |
| 20 | + return os.environ[var_name] |
| 21 | + except KeyError: |
| 22 | + error_msg = 'Set the {} environment variable'.format(var_name) |
| 23 | + raise ImproperlyConfigured(error_msg) |
| 24 | + |
| 25 | + |
| 26 | +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) |
| 27 | + |
| 28 | +# Quick-start development settings - unsuitable for production |
| 29 | +# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ |
| 30 | + |
| 31 | +# SECURITY WARNING: keep the secret key used in production secret! |
| 32 | +SECRET_KEY = get_env_variable('SECRET_KEY') |
| 33 | + |
| 34 | +# SECURITY WARNING: don't run with debug turned on in production! |
| 35 | +DEBUG = os.getenv("DEBUG", False) |
| 36 | + |
| 37 | +ALLOWED_HOSTS = ['*'] |
| 38 | + |
| 39 | +# Tuple of people who get error notifications |
| 40 | +ADMINS = [ |
| 41 | + ( 'Tapasweni Pathak', '[email protected]'), |
| 42 | + ( 'Nikhita Raghunath', '[email protected]'), |
| 43 | + ( 'Ibrahim Jarif', '[email protected]'), |
| 44 | + ( 'Amar Prakash Pandey', '[email protected]') |
| 45 | +] |
| 46 | + |
| 47 | +# Application definition |
| 48 | + |
| 49 | +INSTALLED_APPS = ( |
| 50 | + 'main', |
| 51 | + 'django.contrib.admin', |
| 52 | + 'django.contrib.auth', |
| 53 | + 'django.contrib.contenttypes', |
| 54 | + 'django.contrib.sessions', |
| 55 | + 'django.contrib.messages', |
| 56 | + 'django.contrib.staticfiles', |
| 57 | +) |
| 58 | + |
| 59 | +MIDDLEWARE_CLASSES = ( |
| 60 | + 'whitenoise.middleware.WhiteNoiseMiddleware', |
| 61 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
| 62 | + 'django.middleware.common.CommonMiddleware', |
| 63 | + 'django.middleware.csrf.CsrfViewMiddleware', |
| 64 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 65 | + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
| 66 | + 'django.contrib.messages.middleware.MessageMiddleware', |
| 67 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 68 | +) |
| 69 | + |
| 70 | +ROOT_URLCONF = 'oshc.urls' |
| 71 | + |
| 72 | +WSGI_APPLICATION = 'oshc.wsgi.application' |
| 73 | + |
| 74 | +TEMPLATES = [ |
| 75 | + { |
| 76 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 77 | + 'APP_DIRS': True, |
| 78 | + 'OPTIONS': { |
| 79 | + 'context_processors': [ |
| 80 | + 'django.template.context_processors.debug', |
| 81 | + 'django.template.context_processors.request', |
| 82 | + 'django.contrib.auth.context_processors.auth', |
| 83 | + 'django.contrib.messages.context_processors.messages', |
| 84 | + ], |
| 85 | + }, |
| 86 | + }, |
| 87 | +] |
| 88 | + |
| 89 | +# Database |
| 90 | +# https://docs.djangoproject.com/en/1.7/ref/settings/#databases |
| 91 | + |
| 92 | +DATABASES = { |
| 93 | + 'default': { |
| 94 | + 'ENGINE': 'django.db.backends.sqlite3', |
| 95 | + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +# Get DATABASE_URL environment variable and update default DATABASE settings |
| 100 | +# This setting is required for Heroku |
| 101 | +db_from_env = dj_database_url.config() |
| 102 | +DATABASES['default'].update(db_from_env) |
| 103 | + |
| 104 | +# Internationalization |
| 105 | +# https://docs.djangoproject.com/en/1.7/topics/i18n/ |
| 106 | + |
| 107 | +LANGUAGE_CODE = 'en-us' |
| 108 | + |
| 109 | +TIME_ZONE = 'UTC' |
| 110 | + |
| 111 | +USE_I18N = True |
| 112 | + |
| 113 | +USE_L10N = True |
| 114 | + |
| 115 | +USE_TZ = True |
| 116 | + |
| 117 | +# Simplified static file serving. |
| 118 | +# https://warehouse.python.org/project/whitenoise/ |
| 119 | + |
| 120 | +STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' |
| 121 | + |
| 122 | +# Static files (CSS, JavaScript, Images) |
| 123 | +# https://docs.djangoproject.com/en/1.7/howto/static-files/ |
| 124 | + |
| 125 | +STATIC_URL = '/static/' |
| 126 | +PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) |
| 127 | +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') |
| 128 | + |
| 129 | +STATICFILES_DIRS = ( |
| 130 | + os.path.join(BASE_DIR, 'main/'), |
| 131 | +) |
0 commit comments