-
-
Notifications
You must be signed in to change notification settings - Fork 361
Expand file tree
/
Copy pathsettings.py
More file actions
132 lines (104 loc) · 3.11 KB
/
settings.py
File metadata and controls
132 lines (104 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
SECRET_KEY = 'ey5!m&h-uj6c7dzp@(o1%96okkq4!&bjja%oi*v3r=2t(!$7os'
DEBUG = True
DEBUG_PROPAGATE_EXCEPTIONS = True
ALLOWED_HOSTS = []
INSTALLED_APPS = (
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
'silk',
'example_app'
)
ROOT_URLCONF = 'project.urls'
# Django 3.2+
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'silk.middleware.SilkyMiddleware'
]
WSGI_APPLICATION = 'wsgi.application'
DB_ENGINE = os.environ.get("DB_ENGINE", "postgresql")
DATABASES = {
"default": {
"ENGINE": f"django.db.backends.{DB_ENGINE}",
"NAME": os.environ.get("DB_NAME", "postgres"),
"USER": os.environ.get("DB_USER", 'postgres'),
"PASSWORD": os.environ.get("DB_PASSWORD", "postgres"),
"HOST": os.environ.get("DB_HOST", "127.0.0.1"),
"PORT": os.environ.get("DB_PORT", 5432),
"ATOMIC_REQUESTS": True
},
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOGGING = {
'version': 1,
'formatters': {
'mosayc': {
'format': '%(asctime)-15s %(levelname)-7s %(message)s [%(funcName)s (%(filename)s:%(lineno)s)]',
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'mosayc'
}
},
'loggers': {
'silk': {
'handlers': ['console'],
'level': 'DEBUG'
}
},
}
STATIC_URL = '/static/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
STATIC_ROOT = '/tmp/static/'
if not os.path.exists(STATIC_ROOT):
os.mkdir(STATIC_ROOT)
MEDIA_ROOT = BASE_DIR + '/media/'
MEDIA_URL = '/media/'
if not os.path.exists(MEDIA_ROOT):
os.mkdir(MEDIA_ROOT)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
SILKY_META = True
SILKY_PYTHON_PROFILER = True
SILKY_PYTHON_PROFILER_BINARY = True
# Do not garbage collect for tests
SILKY_MAX_RECORDED_REQUESTS_CHECK_PERCENT = 0
# SILKY_AUTHENTICATION = True
# SILKY_AUTHORISATION = True
SILKY_DISTRIBUTION_TAB = True