“”"
Django settings for DjangoFresh project.

Generated by ‘django-admin startproject’ using Django 2.1.2.

For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/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.1/howto/deployment/checklist/

SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = ‘#*g#)k=c6jjy$cb)2tc&7sz^w)=vj92-=1j80%=69ezgkrlu’

SECURITY WARNING: don’t run with debug turned on in production!

DEBUG = True
ALLOWED_HOSTS = ["*"]#让所有ip访问

Application definition

INSTALLED_APPS = [
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘Store’,
‘Buyer’,
‘ckeditor’,#富文本配置,django自带
‘ckeditor_uploader’,
‘rest_framework’,
‘djcelery’,#django-celery;celery定时任务
]

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’,
#‘DjangoFresh.middleware.MiddlewareTest’,#middleware中间件
]

ROOT_URLCONF = ‘DjangoFresh.urls’

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’,
],
},
},
]

WSGI_APPLICATION = ‘DjangoFresh.wsgi.application’

Database

https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {#数据库配置
‘default’: {
‘ENGINE’: ‘django.db.backends.sqlite3’,
‘NAME’: os.path.join(BASE_DIR, ‘db.sqlite3’),
}
}

Password validation

https://docs.djangoproject.com/en/2.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/2.1/topics/i18n/

LANGUAGE_CODE = ‘zh-hans’#简体字

TIME_ZONE = ‘Asia/Shanghai’#指定时区

USE_I18N = True

USE_L10N = True

USE_TZ = False#为True默认使用utc 0时区

Static files (CSS, JavaScript, Images)

https://docs.djangoproject.com/en/2.1/howto/static-files/

STATIC_URL = ‘/static/’
STATICFILES_DIRS=(
os.path.join(BASE_DIR,“static”),
)
MEDIA_URL="/media/"#长传文件
MEDIA_ROOT=os.path.join(BASE_DIR,“static”)

STATIC_ROOT=os.path.join(BASE_DIR,“static”)#收集静态文件

CKEDITOR_UPLOAD_PATH=‘static/upload’
CKEDITOR_IMAGE_BACKEND=“pillow”#富文本配置
#配置完富文本后要收集静态文件,然后在前端引用,然后运行
REST_FRAMEWORK={
“DEFAULT_PERMISSION_CLASSES”:[
‘rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly’
],
‘DEFAULT_PAGINATION_CLASS’:‘rest_framework.pagination.PageNumberPagination’,
‘PAGE_SIZE’:10,#分页需要,用于后端分页
“DEFAULT_RENDERER_CLASSES”?
‘utils.rendererresponse.customrenderer’,
),
‘DEFAULT_FILTER_BACKENDS’?
‘django_filters.rest_framework.DjangoFilterBackend’,#django-filter自带查询过滤器

)

}
#配置邮件服务器
EMAIL_BACKEND=‘django.core.mail.backends.smtp.EmailBackend’#发送邮件采用smtp服务
EMAIL_USE_TLS=False#使用tls方式
EMAIL_HOST=“smtp.163.com”
EMAIL_POST=465
EMAIL_HOST_USER="18232951692@qq.com"
EMAIL_HOST_PASSWORD=“123aoe”
DEFAUIL_FROM_EMAIL="3303236612@qq.com"

#celery#配置
import djcelery#导入django-celery模块
djcelery.setup_loader()#进行模块加载
BROKER_URL=“redis://127.0.0.1:6379/1”#任务容器地址,redis数据库地址
CELERY_IMPORTS=(‘CeleryTask.tasks’)#具体的任务文件
CELERY_TIMEZONE=‘Asia/Shanghai’#celery时区
CELERYBEAT_SCHEDULER=‘djcelery.schedulers.DatabaseScheduler’#celey处理器,固定
#celery的定时器

#schedules时间表 安排schedules schdeules时间表 安排;celery定时任务用到的包celery celery
from celery.schedules import timedelta#timedelta时间间隔timedelta timedelta时间间隔timedelta
CELERYBEAT_SCHEDULE={#定时器策略
#定时任务一:每隔30s运行一次
u’测试定时器1’:{
“task”:“CeleryTask.tasks.taskExample”,
#"schedule"crontab(minute=’*/2’),#or ‘schedule’: timedelta(seconds=3)
“schedule”:timedelta(seconds=3),#3秒运行一次
“args”?),
},
u’来自天主的问候’:{
“task”:“CeleryTask.tasks.DingTalk”,#文件位置
“schedule”:timedelta(seconds=3),#定时器,每3秒运行一次
“args”?),
},
}

#缓存配置

CACHES={

‘default’:{

‘BACKEND’:‘django.core.cache.backends.memcached.MemcachedCache’,

#申明使用memcache进行缓存

‘LOCATION’:[

‘127.0.0.1:11211’#缓存默认端口

]#memcache地址

}

}

CACHES={

‘default’:{

‘BACKEND’:‘django.core.cache.backends.locmem.LocMemCache’

#默认使用本地缓存

}

}

CACHES={

‘default’:{

‘BACKEND’:‘django_redis.cache.RedisCache’,

‘LOCATION’:[

‘redis://127.0.0.1:6379/1’

],#memcacha地址

‘OPTIONS’:{

‘CLIENT_CLASS’:‘django_redis.client.DefaultClient’

}

}

}

CACHE_MIDDLEWARE_KEY_PREFIX=’’

CACHE_MIDDLEWARE_SECONDS=600#全局缓存的寿命

#数据库缓存
CACHES={
‘default’:{
‘BACKEND’:‘django.core.cache.backends.db.DatabaseCache’,
#默认使用数据库缓存
‘LOCATION’:‘cache_table’#存放缓存的表
}
}

Django完整配置settings.py相关推荐

  1. django项目中settings.py文件中路径设置问题

    2019独角兽企业重金招聘Python工程师标准>>> 首先,__file__表示当前模块的名字. 将下列代码写入os.path.py文件中,存放在桌面上 ""& ...

  2. 设置默认settings文件_Django 学习笔记系列 之 settings.py 设定

    我们在上⼀节中已经创建了⼀个新的功能应⽤,名为newapp_01. 在这一节中,我们要对整个django项目的settings.py文件进行设定.这里settings.py 的主要功能是管理djang ...

  3. django 完整日志配置

    django 完整日志配置 django中的log需要在settings.py中配置 import timecur_path = os.path.dirname(os.path.realpath(__ ...

  4. Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt)...

    Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt) 作者: Desmond Chen, 发布日期: 2014-05 ...

  5. python打开setting_Django自带日志 settings.py文件配置方法

    Django settings.py文件配置部分: # logging配置 log_file = '/home/nagain/learn/log' log_file_path = os.path.jo ...

  6. Django在settings.py设置安装软件路径,遇到 'Settings' object is not subscriptable报错

    1.由于在搞一个导出pdf的功能时,需要指定下面的一个配置,代码如下: config = pdfkit.configuration(wkhtmltopdf='D:\\SoftWare\\wkhtmlt ...

  7. django - settings.py

    settings.py : 一个 python语法 写满 变量 的文件. 1. 启动主程序中,可能是对 一段我不太明白的代码 的解释: On the server (mod_wsgi) In your ...

  8. Scrapy框架的学习(8.scrapy中settings.py里面配置说明以及怎样设置配置或者参数以及怎样使用)

    1.settings.py里面的参数说明 每个参数其对应的官方得文档的网址 # -*- coding: utf-8 -*-# Scrapy settings for tencent project # ...

  9. 解决vscode格式化代码html属性换行问题; ctrl+s格式化去除分号,格式化自动单引号;解决js格式化换行问题;mac上的settings.json完整配置

    右键格式化文档或者ctrl + s保存 html不换行 1.安装两个插件①vetur ②Prettier - Code formatter 2.在vetur的settings.json中设置 配置ct ...

最新文章

  1. Spring MVC 相关资料整理
  2. 软件项目开发流程及配置人员
  3. mybaits二十一:2缓存介绍
  4. 【HDU2795】Billboard(线段树)
  5. MySQL字符串替换
  6. windows下安装rabbitmq以及php扩展amqp
  7. Linux设备驱动之字符设备(二)
  8. Java的GUI学习三(frame)
  9. 矩阵理论及其应用课后习题作业:第三章 第四章
  10. 【python】精简版 如何将图片转化为excel并导出
  11. 如何做好ASO应用优化?ios如何aso优化,android aso 优化
  12. 共享软件作者怎样才能月入万元(一)
  13. 平面解析几何----圆锥曲线1/AF+1/BF=2/ep的三种证法
  14. py2exe 打包 Pmw Error 3 解决方案
  15. 2020东软面试题小计(校招Java篇)
  16. muduo学习笔记:net部分之实现TCP网络编程库-Buffer
  17. MDI窗体与子窗体的显示问题--(如何让主窗体是被控件挡住的子窗体显示)
  18. python 随机选择list或numpy.ndarray中n个元素
  19. 计算机与网络 文献,计算机与网络专著参考文献 计算机与网络参考文献怎么写...
  20. 一坑未平一坑又起——圆锥曲线1-1 椭圆的定义中的东西

热门文章

  1. 多线程与高并发(八):ThreadPoolExecutor源码解析, SingleThreadPool,CachedPool,FixedThreadPool,ForkJoinPoll 等
  2. 【面试】Java面试常见问题汇总(不含答案)、面试指导学习笔记
  3. 【Java爬虫】爬取网页中的内容,提取其中文字
  4. 牛客网_PAT乙级_1013组个最小数 (20)
  5. java安全编码指南之:字符串和编码
  6. C++ vector 使用详解
  7. 蓝桥杯 ADV-205 算法提高 拿糖果
  8. [leetcode] 142.环形链表2
  9. python物性库能调用哪些物质_Python获取热物性(2)使用ctREFPROP调用refprop
  10. Mysql数据库(二)——mysql数据库管理