Coverage for wv_dvs/settings.py : 87%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Django settings for wv_dvs project.
4Generated by 'django-admin startproject' using Django 2.1.
6For more information on this file, see
7https://docs.djangoproject.com/en/2.1/topics/settings/
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.1/ref/settings/
11"""
13import os
14import sys
16# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18TEST_DIR = os.path.join(BASE_DIR, 'wv_dvs/test-documents/')
19APPS_DIR = os.path.join(BASE_DIR, 'apps')
20sys.path.append(APPS_DIR)
23# Quick-start development settings - unsuitable for production
24# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
26# SECURITY WARNING: keep the secret key used in production secret!
27SECRET_KEY = os.environ.get(
28 'DJANGO_SECRET_KEY',
29 '@6+1r=facrz7n7w-k%+z%ean$d$@^2#w-=g5@9+gl@j@dms&gu'
30)
32# SECURITY WARNING: don't run with debug turned on in production!
33DEBUG = os.environ.get('DJANGO_DEBUG', 'True').lower() == 'true'
35ALLOWED_HOSTS = ['*']
38CORS_ORIGIN_ALLOW_ALL = True
40# Application definition
42LOCAL_APPS = [
43 'site_setting',
44 'project',
45 'report',
46 'summary_group',
47]
49INSTALLED_APPS = [
50 'django.contrib.admin',
51 'django.contrib.auth',
52 'django.contrib.contenttypes',
53 'django.contrib.sessions',
54 'django.contrib.messages',
55 'django.contrib.staticfiles',
56 'corsheaders',
58 'rest_framework',
59 'django_filters',
60 'djangorestframework_camel_case',
61 'drf_yasg', # API Documentation
62] + [
63 '{}.{}.apps.{}Config'.format(
64 APPS_DIR.split('/')[-1],
65 app,
66 ''.join([word.title() for word in app.split('_')]),
67 ) for app in LOCAL_APPS
68]
70MIDDLEWARE = [
71 'corsheaders.middleware.CorsMiddleware',
72 'django.middleware.security.SecurityMiddleware',
73 'django.contrib.sessions.middleware.SessionMiddleware',
74 'django.middleware.common.CommonMiddleware',
75 'django.middleware.csrf.CsrfViewMiddleware',
76 'django.contrib.auth.middleware.AuthenticationMiddleware',
77 'django.contrib.messages.middleware.MessageMiddleware',
78 'django.middleware.clickjacking.XFrameOptionsMiddleware',
79]
81ROOT_URLCONF = 'wv_dvs.urls'
83TEMPLATES = [
84 {
85 'BACKEND': 'django.template.backends.django.DjangoTemplates',
86 'DIRS': [os.path.join(APPS_DIR, 'templates')],
87 'APP_DIRS': True,
88 'OPTIONS': {
89 'context_processors': [
90 'django.template.context_processors.debug',
91 'django.template.context_processors.request',
92 'django.contrib.auth.context_processors.auth',
93 'django.contrib.messages.context_processors.messages',
94 ],
95 },
96 },
97]
99WSGI_APPLICATION = 'wv_dvs.wsgi.application'
102# Database
103# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
105DATABASES = {
106 'default': {
107 'ENGINE': 'django.db.backends.postgresql',
108 'NAME': os.environ.get('DATABASE_NAME', 'postgres'),
109 'USER': os.environ.get('DATABASE_USER', 'postgres'),
110 'PASSWORD': os.environ.get('DATABASE_PASSWORD', 'postgres'),
111 'PORT': os.environ.get('DATABASE_PORT', '5432'),
112 'HOST': os.environ.get('DATABASE_HOST', 'db'),
113 }
114}
117# Password validation
118# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
120AUTH_PASSWORD_VALIDATORS = [
121 {
122 'NAME': 'django.contrib.auth.password_validation.'
123 'UserAttributeSimilarityValidator',
124 },
125 {
126 'NAME': 'django.contrib.auth.password_validation.'
127 'MinimumLengthValidator',
128 },
129 {
130 'NAME': 'django.contrib.auth.password_validation.'
131 'CommonPasswordValidator',
132 },
133 {
134 'NAME': 'django.contrib.auth.password_validation.'
135 'NumericPasswordValidator',
136 },
137]
140# Internationalization
141# https://docs.djangoproject.com/en/2.1/topics/i18n/
143LANGUAGE_CODE = 'en-us'
145TIME_ZONE = 'UTC'
147USE_I18N = True
149USE_L10N = True
151USE_TZ = True
154# Static files (CSS, JavaScript, Images)
155# https://docs.djangoproject.com/en/2.1/howto/static-files/
157STATIC_URL = '/django-static/'
158STATIC_ROOT = '/static'
160MEDIA_URL = '/django-media/'
161MEDIA_ROOT = '/media'
163STATICFILES_DIRS = [
164 os.path.join(APPS_DIR, 'static'),
165]
168REST_FRAMEWORK = {
169 'DEFAULT_RENDERER_CLASSES': (
170 'djangorestframework_camel_case.render.CamelCaseJSONRenderer',
171 'rest_framework.renderers.BrowsableAPIRenderer',
172 ),
173 'DEFAULT_PARSER_CLASSES': (
174 'djangorestframework_camel_case.parser.CamelCaseJSONParser',
175 'rest_framework.parsers.FormParser',
176 'rest_framework.parsers.MultiPartParser',
177 ),
178 'JSON_UNDERSCOREIZE': {
179 'no_underscore_before_number': True,
180 },
181}
183REDOC_SETTINGS = {
184 'LAZY_RENDERING': True,
185 'HIDE_HOSTNAME': True,
186 'NATIVE_SCROLLBARS': True,
187 'EXPAND_RESPONSES': [],
188}
190# NOTE: May throw RequestDataTooBig when used.
191if DEBUG and os.environ.get('DJANGO_USE_SILK', 'False').lower() == 'true': 191 ↛ 192line 191 didn't jump to line 192, because the condition on line 191 was never true
192 INSTALLED_APPS += ['silk']
193 MIDDLEWARE += ['silk.middleware.SilkyMiddleware']
194 SILKY_META = True
195 SILKY_PYTHON_PROFILER = True