-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.py
More file actions
379 lines (310 loc) · 10.7 KB
/
settings.py
File metadata and controls
379 lines (310 loc) · 10.7 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
"""
Django settings for eden_cats_blog project.
Generated by 'django-admin startproject' using Django 2.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '=0dnupswsjy%ip$4f4&$02-e7uh-9+w595dsc@r$0v9)i)y298'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
#DEBUG = True
ALLOWED_HOSTS = ['*']
# ALLOWED_HOSTS = [
# '127.0.0.1', # Allow domain and subdomains
# '127.0.0.1:8088', # Allow domain and subdomains
# 'localhost', # Also allow FQDN and subdomains
# ]
#ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'jet.dashboard',
'jet',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'apps.blog', # blog 应用
# 'django_summernote', # 富文本应用
'haystack', # 搜索应用
'mdeditor', # Markdown 应用
# 'mptt', # 树存储结构目录应用
'ckeditor',
'ckeditor_uploader',
'mptt',
'apps.easy_comment',
'notifications',
'apps.online_status',
# 'django.contrib.auth',
'django.contrib.sites',
'allauth', # 用户注册与登录
'allauth.account', # 用户注册与登录
'allauth.socialaccount', # 用户注册与登录
# 下面是第三方账号相关的,比如weibo和github
'allauth.socialaccount.providers.weibo',
'allauth.socialaccount.providers.github',
'allauth.socialaccount.providers.baidu',
'allauth.socialaccount.providers.gitlab',
'crispy_forms',
'imagekit',
'apps.message',
]
# 使用bootstrap3的样式,前端需要引入相应的css
CRISPY_TEMPLATE_PACK = 'bootstrap3'
# django-allauth相关设置
AUTHENTICATION_BACKENDS = (
# django admin所使用的用户登录与django-allauth无关
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
)
# 前面我们app里添加了django.contrib.sites,需要设置SITE_ID
SITE_ID = 2
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'
ACCOUNT_EMAIL_REQUIRED = True
LOGIN_REDIRECT_URL = '/'
# 默认情况下不发邮件通知,开启邮件通知功能后,只有当用户不在线的情况下,才会发邮件。
SEND_NOTIFICATION_EMAIL = False # 不开启邮件通知
# Email setting
# SMTP服务器,使用sendclound的服务
EMAIL_HOST = 'smtp587.sendcloud.net'
EMAIL_HOST_USER = 'TRsky_STMP_Mail'
EMAIL_HOST_PASSWORD = '******'
EMAIL_PORT = 587
# 是否使用了SSL 或者TLS
# EMAIL_USE_SSL = True
# EMAIL_USE_TLS = True
# 默认发件人,默认使用的webmaster@localhost
DEFAULT_FROM_EMAIL = 'TRsky <noreply@mail.trskycooik.com>'
COMMENT_ENTRY_MODEL = 'blog.article' # 格式是 app_name+model_name
AUTH_USER_MODEL = 'blog.User' # 格式是 app_name+model_name
ADMINS = (('TRsky', '625310581@qq.com'),) # 网站管理员
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
# 默认值是'optional',当其等于'mandatory’时,在email未验证之前,本地注册的用户无法登陆。'optional' 和 'none' 则不要求必须验证邮箱,\
# 两者区别是'optional' 依然会发送验证邮件,而'none' 则不会
SOCIALACCOUNT_EMAIL_VERIFICATION = 'mandatory'
# 与ACCOUNT_EMAIL_VERIFICATION 同理,作用于第三方账号的注册,默认值等于前者,
LOGIN_URL = '/accounts/login'
# 如果当前没有登录的用户,则会指向LOGIN_URL
# 邮件通知
# SEND_NOTIFICATION_EMAIL = True # 开启邮件通知
# SMTP设置
# EMAIL_HOST = ''
# EMAIL_HOST_USER = ''
# EMAIL_HOST_PASSWORD = ''
# EMAIL_PORT =
# EMAIL_USE_SSL =
# ckeditor setup
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
CKEDITOR_UPLOAD_PATH = 'upload/'
CKEDITOR_IMAGE_BACKEND = 'pillow'
CKEDITOR_CONFIGS = {
'default': {
# 编辑器的宽高请根据你的页面自行设置
'width': '1030px',
'height': '150px',
'image_previewText': ' ',
'tabSpaces': 4,
'toolbar': 'Custom',
'toolbar_Custom': [
['Bold', 'Italic', 'Underline', 'Format', 'RemoveFormat'],
['NumberedList', 'BulletedList'],
['Blockquote', 'CodeSnippet'],
['Image', 'Link', 'Unlink'],
],
'extraPlugins': ','.join(['codesnippet', 'uploadimage', 'prism', 'widget', 'lineutils', ]),
}
}
# 不允许非图片文件上传,默认为True
CKEDITOR_ALLOW_NONIMAGE_FILES = False
# 限制用户查看上传图片的权限, 只能看自己传的图片
CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_RESTRICT_BY_DATE = True
# 在编辑器里浏览上传的图片时,图片会以路径分组,日期排序
CKEDITOR_BROWSE_SHOW_DIRS = True
# 搜索
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'apps.blog.whoosh_cn_backend.WhooshEngine',
'PATH': os.path.join(BASE_DIR, 'whoosh_index'),
},
}
HAYSTACK_SEARCH_RESULTS_PER_PAGE = 5
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
# 主题
JET_THEMES = [
{
'theme': 'default', # theme folder name
'color': '#47bac1', # color of the theme's button in user menu
'title': 'Default' # theme title
},
{
'theme': 'green',
'color': '#44b78b',
'title': 'Green'
},
{
'theme': 'light-green',
'color': '#2faa60',
'title': 'Light Green'
},
{
'theme': 'light-violet',
'color': '#a464c4',
'title': 'Light Violet'
},
{
'theme': 'light-blue',
'color': '#5EADDE',
'title': 'Light Blue'
},
{
'theme': 'light-gray',
'color': '#222',
'title': 'Light Gray'
}
]
# 静态文件放置
# STATICFILES_DIRS = [
# os.path.join(BASE_DIR, 'static'),
# ]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'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',
# 'apps.online_status.middleware.OnlineStatusMiddleware',
]
# USER_ONLINE_TIMEOUT = 600
ROOT_URLCONF = 'eden_cats_blog.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'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',
],
},
},
]
WSGI_APPLICATION = 'eden_cats_blog.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# },
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'edencatsdb',
'USER': 'root',
'PASSWORD': '******',
'HOST': 'db',
'PORT': '3306',
}
}
# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
PAGE_NUM = 3 # 每页显示 3 篇文章
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
# STATIC_ROOT = 'static' # debug=False
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
# TEMPLATE_DEBUG = False
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
#
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
# 纯文本设置为富文本
#
# MEDIA_URL = '/media/'
# MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
# 富文本编辑器设置
# SUMMERNOTE_CONFIG = {
# Using SummernoteWidget - iframe mode
# 'iframe': True, # or set False to use SummernoteInplaceWidget - no iframe mode
# Using Summernote Air-mode
# 'airMode': False,
# Use native HTML tags (`<b>`, `<i>`, ...) instead of style attributes
# 'styleWithSpan': False,
# Change editor size
# 'width': '80%',
# 'height': '480',
#
# Use proper language setting automatically (default)
# 'lang': 'zh-CN',
# }
# Markdown django-mdeditor
# MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
# MEDIA_URL = '/media/'
# Markdown 语法设置
MDEDITOR_CONFIGS = {
'default': {
'width': '90%',
'heigth': 1000, # markdown 编辑框高度
'toolbar': ["undo", "redo", "|",
"bold", "del", "italic", "quote", "ucwords", "uppercase",
"lowercase", "|",
"h1", "h2", "h3", "h5", "h6", "|",
"list-ul", "list-ol", "hr", "|",
"link", "reference-link", "image", "code",
"preformatted-text", "code-block", "table", "datetime",
"emoji", "html-entities", "pagebreak", "goto-line", "|",
"help", "info",
"||", "preview", "watch", "fullscreen"],
'upload_image_formats': ["jpg", "JPG", "jpeg", "JPEG", "gif", "GIF",
"png", "PNG", "bmp", "BMP", "webp", "WEBP"],
'image_floder': 'editor',
'theme': 'default', # dark / default
'preview_theme': 'default', # dark / default
'editor_theme': 'default', # pastel-on-dark / default
'toolbar_autofixed': True,
'search_replace': True,
'emoji': True,
'tex': True,
'flow_chart': True,
'sequence': True
}
}