1import os
2import sentry_sdk
3from sentry_sdk.integrations.django import DjangoIntegration
4
5from pathlib import Path
6
7# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
8BASE_DIR = Path(__file__).resolve().parent.parent
9
10# Quick-start development settings - unsuitable for production
11# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
12
13# SECURITY WARNING: keep the secret key used in production secret!
14SECRET_KEY = os.environ.get('SECRET_KEY')
15
16
17# SECURITY WARNING: don't run with debug turned on in production!
18
19DEBUG = bool(os.environ.get('DEBUG', default=False))
20ALLOWED_HOSTS = ['orange-county-lettings.azurewebsites.net',
21 '127.0.0.1',
22 '.localhost',
23 '0.0.0.0',
24 'google.com',
25 '[::1]'] if DEBUG is False else []
26
27# Application definition
28
29INSTALLED_APPS = [
30 'django.contrib.admin',
31 'django.contrib.auth',
32 'django.contrib.contenttypes',
33 'django.contrib.sessions',
34 'django.contrib.messages',
35 'django.contrib.staticfiles',
36 'oc_lettings_site',
37 'lettings',
38 'profiles',
39]
40
41MIDDLEWARE = [
42 'django.middleware.security.SecurityMiddleware',
43 'whitenoise.middleware.WhiteNoiseMiddleware',
44 'django.contrib.sessions.middleware.SessionMiddleware',
45 'django.middleware.common.CommonMiddleware',
46 'django.middleware.csrf.CsrfViewMiddleware',
47 'django.contrib.auth.middleware.AuthenticationMiddleware',
48 'django.contrib.messages.middleware.MessageMiddleware',
49 'django.middleware.clickjacking.XFrameOptionsMiddleware',
50]
51
52ROOT_URLCONF = 'oc_lettings_site.urls'
53
54TEMPLATES = [
55 {
56 'BACKEND': 'django.template.backends.django.DjangoTemplates',
57 'DIRS': [os.path.join(BASE_DIR, 'templates')],
58 'APP_DIRS': True,
59 'OPTIONS': {
60 'context_processors': [
61 'django.template.context_processors.debug',
62 'django.template.context_processors.request',
63 'django.contrib.auth.context_processors.auth',
64 'django.contrib.messages.context_processors.messages',
65 ],
66 },
67 },
68]
69
70WSGI_APPLICATION = 'oc_lettings_site.wsgi.application'
71
72# Database
73# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
74
75DATABASES = {
76 'default': {
77 'ENGINE': 'django.db.backends.sqlite3',
78 'NAME': os.path.join(BASE_DIR, 'oc-lettings-site.sqlite3'),
79 }
80}
81
82# Password validation
83# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
84
85AUTH_PASSWORD_VALIDATORS = [
86 {
87 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
88 },
89 {
90 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
91 },
92 {
93 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
94 },
95 {
96 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
97 },
98]
99
100# Internationalization
101# https://docs.djangoproject.com/en/3.0/topics/i18n/
102
103LANGUAGE_CODE = 'en-us'
104
105TIME_ZONE = 'UTC'
106
107USE_I18N = True
108
109# USE_L10N = True depreciate
110
111USE_TZ = True
112
113# Static files (CSS, JavaScript, Images)
114# https://docs.djangoproject.com/en/3.0/howto/static-files/
115
116STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
117
118STATIC_URL = 'staticfiles/'
119STATICFILES_DIRS = [BASE_DIR / "static", ]
120
121STORAGES = {
122 "default": {
123 "BACKEND": "django.core.files.storage.FileSystemStorage",
124 },
125 "staticfiles": {
126 "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
127 },
128}
129
130DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
131
132SECURE_PROXY_SSL_HEADER = None
133SECURE_SSL_REDIRECT = False
134SESSION_COOKIE_SECURE = False
135CSRF_COOKIE_SECURE = False
136
137
[docs]
138def profiles_sampler(sampling_context):
139 # ...
140 # return a number between 0 and 1 or a boolean
141 return True
142
143
144sentry_sdk.init(
145 dsn=os.environ.get('DSN'),
146 # Set traces_sample_rate to 1.0 to capture 100%
147 # of transactions for performance monitoring.
148 # We recommend adjusting this value in production.
149 traces_sample_rate=1.0,
150 # Set profiles_sample_rate to 1.0 to profile 100%
151 # of sampled transactions.
152 # We recommend adjusting this value in production.
153 profiles_sample_rate=1.0,
154
155 # Alternatively, to control sampling dynamically
156 profiles_sampler=profiles_sampler,
157
158 integrations=[
159 DjangoIntegration(
160 transaction_style='url',
161 middleware_spans=True,
162 signals_spans=True,
163 cache_spans=True,
164 ),
165 ],
166 send_default_pii=True
167)