从头学习开发django系列-setting文件配置,以SAE为例
来源:互联网 发布:淘宝嘉年华怎么 编辑:程序博客网 时间:2024/06/05 18:11
在这里不详细说明每一条的配置,只对重要的进行说明:
接上一篇“环境配置”中新建的工程,在hello目录会有一个setting文件。修改此文件,或许直接上个已经配好的文件更能说明问题。
DEBUG = True #正式发布时,改成FalseTEMPLATE_DEBUG = DEBUGADMINS = ( # ('Your Name', 'your_email@example.com'),)MANAGERS = ADMINSLOGIN_URL = '/login/' #未登陆用户跳转到此urlimport osBASE_DIR = os.path.dirname(os.path.dirname(__file__))SETTINGS_PATH = os.path.normpath(os.path.dirname(__file__)) #get the directory path of this scriptpath=SETTINGS_PATH.split('\\')SET_PATH='/'.join(path[:len(path)-1]) #get the upper level directory#静态文件目录STATICFILES_DIRS = ( ('common_static', ''.join([SET_PATH, '/static/common_static']).replace('\\','/')), )STATIC_ROOT = ''.join([SET_PATH, '/static']).replace('\\','/')# URL prefix for static files.STATIC_URL = '/static/' #configure the url path for using replace for the STATICFILES_DIRS#模板目录TEMPLATE_DIRS = ( ''.join([SET_PATH, '/templates']).replace('\\','/'), os.path.join(os.path.dirname(__file__), 'templates'), )#SAE mysql配置 兼容本地mysql,会自动判断if 'SERVER_SOFTWARE' in os.environ: from sae.const import ( MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASS, MYSQL_DB )else: # Make `python manage.py syncdb` works happy! MYSQL_HOST = 'localhost' MYSQL_PORT = '3306' MYSQL_USER = 'root' MYSQL_PASS = 'root' MYSQL_DB = 'app_pylabs'DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': MYSQL_DB, 'USER': MYSQL_USER, 'PASSWORD': MYSQL_PASS, 'HOST': MYSQL_HOST, 'PORT': MYSQL_PORT, }}# Hosts/domain names that are valid for this site; required if DEBUG is False# See https://docs.djangoproject.com/en/1.4/ref/settings/#allowed-hostsALLOWED_HOSTS = []#根url配置文件ROOT_URLCONF = 'hello.urls'#安装的appINSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'hello', )# Python dotted path to the WSGI application used by Django's runserver.WSGI_APPLICATION = 'wxshop.wsgi.application'# Make this unique, and don't share it with anybody.SECRET_KEY = 'ia!818wkbn_h$k@ss%i#%zb1he744ef@_w*xllok=z8^qh6+vg'# List of finder classes that know how to find static files in# various locations.STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', )# List of callables that know how to import templates from various sources.TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', )MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', )TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.request" )#语言LANGUAGE_CODE = 'zh-cn'#时区,影响时间TIME_ZONE = 'Asia/Shanghai'SITE_ID = 1# If you set this to False, Django will make some optimizations so as not# to load the internationalization machinery.USE_I18N = True# If you set this to False, Django will not format dates, numbers and# calendars according to the current locale.USE_L10N = True# If you set this to False, Django will not use timezone-aware datetimes.USE_TZ = True# A sample logging configuration. The only tangible logging# performed by this configuration is to send an email to# the site admins on every HTTP 500 error when DEBUG=False.# See http://docs.djangoproject.com/en/dev/topics/logging for# more details on how to customize your logging configuration.LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, }}
下一篇 创建app
- 从头学习开发django系列-setting文件配置,以SAE为例
- 从头开始学习开发django系列-1、配置环境,以windows为例
- SAE Django配置static文件
- 从头学习开发django系列-图书教程推荐
- 从头学习开发Django系列-自定义标签和过滤器
- Python+Django+SAE系列教程6-----本地配置Django
- Python+Django+SAE系列教程7-----在Sae上配置Django
- SAE 环境 django 配置
- Python+Django+SAE系列教程12-----配置MySQL数据库
- Python+Django+SAE系列教程4-----操作文件
- 在sae配置django项目
- Django学习——setting.py常用配置
- Django学习——setting.py常用配置
- mysql安装配置以及在django中的配置(windows版,以mysql5.6为例)
- sae+django配置记录(一)
- Python+Django+SAE系列教程8-----Django基础
- Python+Django+SAE系列教程10-----Django的模板
- eclipse django sae网站开发流程
- debian 增加 nginx 自启动脚本
- 让浏览器显示PHP遇到的错误信息
- debian 用户和组操作
- Swing组件使用-弹出式菜单
- POJ题目分类
- 从头学习开发django系列-setting文件配置,以SAE为例
- DEBIAN下中文显示
- 排序算法集合
- 【Qt】搭建QT和VS2010集成开发环境
- 职场潜规则
- VS2010读写Excel
- 折扣达人iPad版
- Debian 6.0.4安装配置lamp(Apache+MySQL+PHP)
- C++中Static作用和使用方法