mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
215 lines
6.7 KiB
Python
215 lines
6.7 KiB
Python
"""
|
|
Django settings for djangoProject project.
|
|
|
|
Generated by 'django-admin startproject' using Django 4.0.6.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/4.0/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/4.0/ref/settings/
|
|
"""
|
|
import os
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = 'django-insecure-6wrh^t$@gbb^s^=79@%cv=%yhq6gl^kane#g@-n-*n6+s1lo2f'
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
# if os.environ.get('DJANGO_DEBUG'):
|
|
# print("Debug is enabled.")
|
|
# DEBUG = True
|
|
# # When not specified, ALLOW_HOSTS defaults to:
|
|
# # ALLOWED_HOSTS = ['localhost', '127.0.0.1', '[::1]']
|
|
# else:
|
|
# DEBUG = False
|
|
DEBUG = True
|
|
|
|
ALLOWED_HOSTS = ['*']
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'simpleui',
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'import_export',
|
|
'django_apscheduler',
|
|
'pt_site',
|
|
'auto_pt',
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
# 'django.middleware.cache.UpdateCacheMiddleware', # redis1
|
|
'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',
|
|
# 'django.middleware.cache.FetchFromCacheMiddleware', # redis2
|
|
|
|
]
|
|
|
|
ROOT_URLCONF = 'ptools.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [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 = 'ptools.wsgi.application'
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': BASE_DIR / 'db/db.sqlite3',
|
|
'OPTIONS': {
|
|
'timeout': 60,
|
|
'check_same_thread': False
|
|
}
|
|
},
|
|
# 'default': {
|
|
# 'ENGINE': 'django.db.backends.mysql', # 数据库引擎
|
|
# 'NAME': 'pt', # 数据库名,先前创建的
|
|
# 'USER': 'pt', # 用户名,可以自己创建用户
|
|
# 'PASSWORD': 'bfmAjPysaFkmWsfs', # 密码
|
|
# 'HOST': 'docker_db_1', # mysql服务所在的主机ip
|
|
# 'PORT': '3306', # mysql服务端口
|
|
# },
|
|
# 'default': {
|
|
# 'ENGINE': 'django.db.backends.mysql', # 数据库引擎
|
|
# 'NAME': 'pt', # 数据库名,先前创建的
|
|
# 'USER': 'pt', # 用户名,可以自己创建用户
|
|
# 'PASSWORD': 'bfmAjPysaFkmWsfs', # 密码
|
|
# 'HOST': 'bt.9oho.cn', # mysql服务所在的主机ip
|
|
# 'PORT': '3306', # mysql服务端口
|
|
# }
|
|
}
|
|
|
|
CACHES = {
|
|
'default': {
|
|
'BACKEND': 'django_redis.cache.RedisCache',
|
|
# 'LOCATION': "redis://127.0.0.1:6333",
|
|
'LOCATION': "redis://127.0.0.1:6379/0",
|
|
'TIMEOUT': 200, # NONE 永不超时
|
|
'OPTIONS': {
|
|
# "PASSWORD": "", # 密码,没有可不设置
|
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient', # redis-py 客户端
|
|
'PICKLE_VERSION': -1, # 插件使用PICKLE进行序列化,-1表示最新版本
|
|
'CONNECTION_POOL_KWARGS': {"max_connections": 100}, # 连接池最大连接数
|
|
'SOCKET_CONNECT_TIMEOUT': 5, # 连接超时
|
|
'SOCKET_TIMEOUT': 5, # 读写超时
|
|
}
|
|
# "KEY_PREFIX ":"test",#前缀
|
|
}
|
|
}
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/4.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/4.0/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'zh-Hans'
|
|
|
|
TIME_ZONE = 'Asia/Shanghai'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_TZ = False
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/4.0/howto/static-files/
|
|
|
|
STATIC_URL = 'static/'
|
|
# STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
|
STATICFILES_DIRS = (
|
|
os.path.join(os.path.join(BASE_DIR, 'static')),
|
|
)
|
|
MEDIA_URL = 'media/'
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
APSCHEDULER_DATETIME_FORMAT = 'Y-m-d H:i:s' # Default
|
|
# 自定义配置
|
|
SIMPLEUI_HOME_TITLE = 'PT一下你就知道'
|
|
SIMPLEUI_HOME_ICON = 'fa fa-optin-monster'
|
|
SIMPLEUI_HOME_INFO = False
|
|
SIMPLEUI_LOGO = '/static/logo1.png'
|
|
# SIMPLEUI配置
|
|
SIMPLEUI_CONFIG = {
|
|
'system_keep': True,
|
|
# 'menu_display': ['下载管理', ], # 开启排序和过滤功能, 不填此字段为默认排序和全部显示, 空列表[] 为全部不显示.
|
|
'dynamic': True, # 设置是否开启动态菜单, 默认为False. 如果开启, 则会在每次用户登陆时动态展示菜单内容
|
|
'menus': [{
|
|
'app': 'downloader',
|
|
'name': '下载管理',
|
|
'icon': 'fas fa-user-shield',
|
|
'models': [{
|
|
'name': '任务管理',
|
|
'icon': 'fa fa-user',
|
|
'url': '/downloader/downloading/index'
|
|
}, {
|
|
'name': '查询种子',
|
|
'icon': 'fa fa-user',
|
|
'url': '/downloader/ptspider/index'
|
|
}]
|
|
}, {
|
|
'app': 'update',
|
|
'name': '更新',
|
|
'icon': 'fas fa-code',
|
|
'models': [{
|
|
'name': '重启更新',
|
|
'icon': 'far fa-surprise',
|
|
'url': '/tasks/restart'
|
|
}, ]
|
|
}]
|
|
}
|