-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_settings.py
264 lines (235 loc) · 7.79 KB
/
docker_settings.py
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
# -*- coding: utf-8 -*-
from pathlib import Path
from django.contrib import admin
BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = 'django-insecure-v%!69-+jqak^*4b+y5uz_udp-l^#ii$6w)qrm&khj2anfc25z&'
DEBUG = True
ALLOWED_HOSTS = ['*']
INSTALLED_APPS = [
'simpleui',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog.apps.BlogConfig',
'import_export',
'mdeditor',
'captcha',
'mptt',
]
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',
# 网站gzip压缩中间件
'django.middleware.gzip.GZipMiddleware',
]
ROOT_URLCONF = 'djangoProject.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'] # noqa
,
'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',
# 上下文处理器
'blog.context_processors.sidebar',
'blog.context_processors.website_conf',
# templates中使用 {{ MEDIA_URL }}{{ 文件名 }} 拼接文件地址
'django.template.context_processors.media',
],
# 用于在模板中自动调用静态文件,不需要每个页面使用 {% load static %} 加载静态文件
'builtins': [
'django.templatetags.static',
],
},
},
]
WSGI_APPLICATION = 'djangoProject.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'blog',
'USER': 'root',
'PASSWORD': '123456',
'HOST': 'dblog_mysql',
'PORT': '3306',
'OPTIONS': {'charset': 'utf8mb4'} # 字符集设置utf8mb4
}
}
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://""@dblog_redis:6379/0",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
}
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',
},
]
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = False
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'static'
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'static/media'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# simpleui 排序后台app导航栏
SIMPLEUI_CONFIG = {
'system_keep': True,
'menu_display': ['文章', '文章配置', '网站配置', '公告', '文章订阅', '审核', '权限验证', ],
'dynamic': True,
'menus': [{
'name': '文章',
'models': [{
'name': '文章',
'url': '/admin/blog/article'
}, {
'name': '评论',
'url': '/admin/blog/comment'
}]
}, {
'name': '文章配置',
'models': [{
'name': '文章大头图',
'icon': 'fa fa-image',
'url': '/admin/blog/articleimg'
}, {
'name': '文章类型',
'icon': 'fa fa-list',
'url': '/admin/blog/category'
}, {
'name': '标签',
'icon': 'fa fa-tags',
'url': '/admin/blog/tag'
}]
}, {
'name': '网站配置',
'models': [{
'name': '网站基本配置',
'url': '/admin/blog/conf'
}, {
'name': '首页轮播图配置',
'url': '/admin/blog/carousel'
}, {
'name': '友链',
'icon': 'fa fa-link',
'url': '/admin/blog/friend'
}, {
'name': '收款图',
'icon': 'fa fa-coffee',
'url': '/admin/blog/pay'
}, {
'name': "关于",
'icon': 'fa fa-id-card',
'url': '/admin/blog/about'
}]
}, {
'name': '公告',
'models': [{
'name': '轮播公告',
'icon': 'fas fa-bullhorn',
'url': '/admin/blog/headannouncement'
}, {
'name': '主公告',
'icon': 'fas fa-bullhorn',
'url': '/admin/blog/mainannouncement'
}, ]
}, {
'name': '审核',
'models': [{
'name': '举报',
'icon': 'fa fa-exclamation-triangle',
'url': '/admin/blog/tipoff'
}]
}, {
'name': '文章订阅',
'models': [{
'name': '订阅用户',
'icon': 'fa fa-address-book',
'url': '/admin/blog/subscription'
}]
}, {
'name': '权限验证',
'icon': 'fas fa-user-shield',
'models': [{
'name': '用户',
'icon': 'fa fa-user',
'url': 'auth/user/'
}, ]
}]
}
# 网站默认配置
# 配置使用优先级:1.数据库(两分钟redis缓存), 2.本地
main_website = 'xwboy.top'
name = "CL' WU"
chinese_description = '永不放弃坚持就是这么酷!要相信光'
english_description = 'Never give up persistence is so cool!Believe in the light'
avatar_link = 'https://oscimg.oschina.net/oscnet/up-8c492f6804d9e46184f2c0e4e02c2671.jpg!/both/200x200'
website_author = 'xiaowu'
website_author_link = 'http://127.0.0.1:8000'
email = '[email protected]'
website_number = ''
git = 'https://gitee.com/wu_cl'
website_logo = '/static/images/logo/DBlog.png'
# simpleui本地配置
# SIMPLEUI_LOGO:对官方css进行了某些修改以适应后台尺寸,使用个人logo时根据显示情况自行修改即可...
SIMPLEUI_LOGO = 'http://127.0.0.1:8000/static/images/logo/DBlog.png'
SIMPLEUI_HOME_TITLE = 'DBlog后台管理'
SIMPLEUI_ANALYSIS = False
SIMPLEUI_LOADING = False
SIMPLEUI_DEFAULT_ICON = True
SIMPLEUI_HOME_INFO = False
# 后台header, title
admin.AdminSite.site_header = SIMPLEUI_HOME_TITLE
admin.AdminSite.site_title = SIMPLEUI_HOME_TITLE
# 登录后重定向到主页面
LOGIN_URL = '/blog/login'
# session设置
SESSION_COOKIE_AGE = 86400 # Session的cookie失效日期(秒)
SESSION_EXPIRE_AT_BROWSER_CLOSE = True # 是否关闭浏览器使得Session过期
SESSION_SAVE_EVERY_REQUEST = False # 是否每次请求都保存Session,默认修改之后才保存
# 字母验证码
CAPTCHA_IMAGE_SIZE = (100, 36) # 设置 captcha 图片大小
CAPTCHA_LENGTH = 4 # 字符个数
CAPTCHA_TIMEOUT = 3 # 超时(minutes)
# SMTP服务器
# 请更改为自己的邮箱配置
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.qq.com'
EMAIL_HOST_USER = '[email protected]'
# 密码(请替换为你自己的哟) qq为设置=>账户=>POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务=> 开启服务POP3/SMTP服务=> 生成授权码
EMAIL_HOST_PASSWORD = 'xxxvszjyenrlvfkeaef'
# 发送邮件端口和加密(两种方式不能同时使用)
# 云服务器使用:
EMAIL_PORT = 465
EMAIL_USE_SSL = True
# 默认的发件人
DEFAULT_FROM_EMAIL = 'xiaowu的个人博客'