Coverage for pear\settings.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Django settings for this project.
4Generated by 'django-admin startproject' using Django 3,2,4.
6For more information on this file, see
7https://docs.djangoproject.com/en/3.2/topics/settings/
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/3.2/ref/settings/
11"""
13from pathlib import Path
14import os
16# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17BASE_DIR = Path(__file__).resolve().parent.parent
19SETTINGS_PATH = Path(__file__).resolve().parent
22# Quick-start development settings - unsuitable for production
23# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
25# SECURITY WARNING: keep the secret key used in production secret!
26# The SECRET_KEY is provided via an environment variable in OpenShift
27SECRET_KEY = os.getenv(
28 'DJANGO_SECRET_KEY',
29 # safe value used for development when DJANGO_SECRET_KEY might not be set
30 '9e4@&tw46$l31)zrqe3wi+-slqm(ruvz&se0^%9#6(_w3ui!c0'
31)
33# SECURITY WARNING: don't run with debug turned on in production!
34DEBUG = True
36ALLOWED_HOSTS = ['*']
39# Application definition
41INSTALLED_APPS = [
42 'django.contrib.admin',
43 'django.contrib.auth',
44 'django.contrib.contenttypes',
45 'django.contrib.sessions',
46 'django.contrib.messages',
47 'django.contrib.staticfiles',
48 'debug_toolbar',
50 # 3rd party apps
51 'rest_framework', # new
52 'rest_framework.authtoken', # new
53 'rest_auth', # new
54 'django.contrib.sites', # new
55 'allauth', # new
56 'allauth.account', # new
57 'allauth.socialaccount', # new
58 'rest_auth.registration', # new
59 'corsheaders', # new
60 'magic',
62 # local apps
63 'dashboard',
64 'users'
65]
69MIDDLEWARE = [
70 'corsheaders.middleware.CorsMiddleware',
71 'django.middleware.security.SecurityMiddleware',
72 'django.contrib.sessions.middleware.SessionMiddleware',
73 'django.middleware.common.CommonMiddleware',
74 'django.middleware.csrf.CsrfViewMiddleware',
75 'django.contrib.auth.middleware.AuthenticationMiddleware',
76 'django.contrib.messages.middleware.MessageMiddleware',
77 'django.middleware.clickjacking.XFrameOptionsMiddleware',
78 'whitenoise.middleware.WhiteNoiseMiddleware',
79 'debug_toolbar.middleware.DebugToolbarMiddleware',
80]
82CORS_ORIGIN_ALLOW_ALL = True
86ROOT_URLCONF = 'pear.urls'
88TEMPLATES = [
89 {
90 'BACKEND': 'django.template.backends.django.DjangoTemplates',
91 'DIRS': ["templates",
92 "dashboard/templates"],
93 'APP_DIRS': True,
94 'OPTIONS': {
95 'context_processors': [
96 'django.template.context_processors.debug',
97 'django.template.context_processors.request',
98 'django.contrib.auth.context_processors.auth',
99 'django.contrib.messages.context_processors.messages',
100 ],
101 },
102 },
103]
105WSGI_APPLICATION = 'pear.wsgi.application'
108# Database
109# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
112DATABASES = {
113 'default': {
114 'ENGINE': 'django.db.backends.postgresql_psycopg2',
115 # 'NAME': os.getenv('DJANGO_DB_NAME', 'django_db'),
116 # 'USER': os.getenv('DATABASE_USER', 'django'),
117 # 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'afiLQho3r50iSoKb'),
118 # 'HOST': os.getenv('DJANGO_DB_HOST', '172.30.186.143'),
119 'NAME': os.getenv('DJANGO_DB_NAME', 'postgres'),
120 'USER': os.getenv('DATABASE_USER', 'postgres'),
121 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'postgres'),
122 'HOST': os.getenv('DJANGO_DB_HOST', 'localhost'),
123 'PORT': os.getenv('DJANGO_DB_PORT', '5432'),
124 }
125}
127# https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys
128DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
130# Password validation
131# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
133AUTH_PASSWORD_VALIDATORS = [
134 {
135 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
136 },
137 {
138 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
139 },
140 {
141 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
142 },
143 {
144 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
145 },
146]
148EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
150AUTHENTICATION_BACKENDS = [
151 "django.contrib.auth.backends.ModelBackend",
152 "allauth.account.auth_backends.AuthenticationBackend",
153]
155SITE_ID = 1
156ACCOUNT_EMAIL_REQUIRED = True
157ACCOUNT_USERNAME_REQUIRED = False
158ACCOUNT_SESSION_REMEMBER = True
159ACCOUNT_AUTHENTICATION_METHOD = 'email'
160ACCOUNT_UNIQUE_EMAIL = True
162REST_FRAMEWORK = {
163 'DATETIME_FORMAT': "%m/%d/%Y %I:%M%P",
164 'DEFAULT_AUTHENTICATION_CLASSES': [
165 'rest_framework.authentication.BasicAuthentication',
166 'rest_framework.authentication.TokenAuthentication',
167 'rest_framework.authentication.SessionAuthentication',
168 ],
169 # 'DEFAULT_PERMISSION_CLASSES': [
170 # 'rest_framework.permissions.IsAuthenticated',
171 # ]
172}
174# Internationalization
175# https://docs.djangoproject.com/en/3.2/topics/i18n/
177LANGUAGE_CODE = 'en-us'
179TIME_ZONE = 'UTC'
181USE_I18N = True
183USE_L10N = True
185USE_TZ = True
188# Static files (CSS, JavaScript, Images)
189# https://docs.djangoproject.com/en/3.2/howto/static-files/
191STATIC_URL = '/static/'
192STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
194STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
196STATIC_URL = '/static/'
198AUTH_USER_MODEL = 'users.CustomUser'
200DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
202ACCEPTABLE_FILE_TYPES = {'.xlsx', '.csv'}
204INTERNAL_IPS = ['127.0.0.1']