You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
4.7 KiB
173 lines
4.7 KiB
"""
|
|
Django settings for guetproject project.
|
|
|
|
Generated by 'django-admin startproject' using Django 3.1.4.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/3.1/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/3.1/ref/settings/
|
|
"""
|
|
|
|
from pathlib import Path
|
|
import os
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = 'kh&847zvb=o(_-ts7#9q-15jp0%l#$_^xqps2)_to-!d0a&d#r'
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = True
|
|
|
|
ALLOWED_HOSTS = ['*',] #为了方便后期部署和访问,需要开放访问权限
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'aboutApp', #公司简介
|
|
'contactApp', #人才招聘
|
|
'homeApp', #首页
|
|
'newsApp', #新闻动态
|
|
'productsApp', #产品中心
|
|
'scienceApp', #科研基地
|
|
'serviceApp', #服务支持
|
|
'DjangoUeditor', #添加富文本应用
|
|
'haystack', #添加搜索应用
|
|
'widget_tweaks', # 添加模型表单组件定制化渲染应用
|
|
|
|
]
|
|
|
|
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',
|
|
]
|
|
|
|
ROOT_URLCONF = 'guetproject.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [os.path.join(BASE_DIR,'templates')], #将项目根目录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 = 'guetproject.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': BASE_DIR / 'db.sqlite3',
|
|
}
|
|
}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/3.1/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/3.1/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'zh-Hans' #设置语言为中文
|
|
|
|
TIME_ZONE = 'Asia/Shanghai' #设置中国时区
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
# STATICFILES_DIRS = (
|
|
# os.path.join(BASE_DIR,"static"),
|
|
# ) #告诉django模板当前共享的静态资源路径位置
|
|
STATICFILES_DIRS = (
|
|
BASE_DIR.joinpath('static'),
|
|
)
|
|
# STATIC_ROOT = os.path.join(BASE_DIR,'static')
|
|
|
|
MEDIA_URL = '/media/' #当前项目的媒体资源文件(此处指图像)的存储根路径韦/media/
|
|
MEDIA_ROOT = os.path.join(BASE_DIR,'media/')
|
|
|
|
# 新闻搜索配置django-haystack
|
|
HAYSTACK_CONNECTIONS = {
|
|
'default': {
|
|
'ENGINE': 'newsApp.whoosh_backend.WhooshEngine',
|
|
'PATH': os.path.join(BASE_DIR, 'whoosh_index'),
|
|
},
|
|
}
|
|
HAYSTACK_SEARCH_RESULTS_PER_PAGE = 10
|
|
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
|
|
|
|
|
|
# 邮箱设置
|
|
EMAIL_HOST = 'smtp.qq.com'
|
|
EMAIL_PORT = 25
|
|
EMAIL_HOST_USER = '1049453191@qq.com' # QQ 账号
|
|
EMAIL_HOST_PASSWORD = 'rpvzuaaeckdsbdjc' # 授权码
|
|
EMAIL_USE_TLS = True
|
|
|
|
#配置缓存表
|
|
CACHES = {
|
|
'default': {
|
|
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
|
|
'LOCATION': 'cache_table_home',
|
|
'TIMEOUT': 600,
|
|
'OPTIONS': {
|
|
'MAX_ENTRIES': 2000
|
|
}
|
|
}
|
|
} |