Commit b9bb6bcb03cfb51f7c1d5e759f311115a07cde67

Authored by zhenchaozhu
1 parent 17cba28932
Exists in master and in 1 other branch de

去除页面缓存中间件

Showing 1 changed file with 0 additions and 1 deletions   Show diff stats
1 # coding: utf-8 1 # coding: utf-8
2 # Django settings for xp project. 2 # Django settings for xp project.
3 3
4 DEBUG = True 4 DEBUG = True
5 TEMPLATE_DEBUG = DEBUG 5 TEMPLATE_DEBUG = DEBUG
6 6
7 ADMINS = ( 7 ADMINS = (
8 # ('Your Name', 'your_email@example.com'), 8 # ('Your Name', 'your_email@example.com'),
9 ) 9 )
10 10
11 MANAGERS = ADMINS 11 MANAGERS = ADMINS
12 12
13 DATABASES = { 13 DATABASES = {
14 'default': { 14 'default': {
15 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 15 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
16 'NAME': 'forum', # Or path to database file if using sqlite3. 16 'NAME': 'forum', # Or path to database file if using sqlite3.
17 # The following settings are not used with sqlite3: 17 # The following settings are not used with sqlite3:
18 'USER': 'root', 18 'USER': 'root',
19 'PASSWORD': 'nineteen', 19 'PASSWORD': 'nineteen',
20 'HOST': '127.0.0.1', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. 20 'HOST': '127.0.0.1', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
21 'PORT': '3306', # Set to empty string for default. 21 'PORT': '3306', # Set to empty string for default.
22 } 22 }
23 } 23 }
24 24
25 # Hosts/domain names that are valid for this site; required if DEBUG is False 25 # Hosts/domain names that are valid for this site; required if DEBUG is False
26 # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts 26 # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
27 ALLOWED_HOSTS = ['*'] 27 ALLOWED_HOSTS = ['*']
28 28
29 # Local time zone for this installation. Choices can be found here: 29 # Local time zone for this installation. Choices can be found here:
30 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 30 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
31 # although not all choices may be available on all operating systems. 31 # although not all choices may be available on all operating systems.
32 # In a Windows environment this must be set to your system time zone. 32 # In a Windows environment this must be set to your system time zone.
33 TIME_ZONE = 'Asia/Shanghai' 33 TIME_ZONE = 'Asia/Shanghai'
34 34
35 # Language code for this installation. All choices can be found here: 35 # Language code for this installation. All choices can be found here:
36 # http://www.i18nguy.com/unicode/language-identifiers.html 36 # http://www.i18nguy.com/unicode/language-identifiers.html
37 LANGUAGE_CODE = 'zh-CN' 37 LANGUAGE_CODE = 'zh-CN'
38 38
39 SITE_ID = 1 39 SITE_ID = 1
40 40
41 # If you set this to False, Django will make some optimizations so as not 41 # If you set this to False, Django will make some optimizations so as not
42 # to load the internationalization machinery. 42 # to load the internationalization machinery.
43 USE_I18N = True # 只有用admin的时候需要开启 43 USE_I18N = True # 只有用admin的时候需要开启
44 44
45 # If you set this to False, Django will not format dates, numbers and 45 # If you set this to False, Django will not format dates, numbers and
46 # calendars according to the current locale. 46 # calendars according to the current locale.
47 USE_L10N = False 47 USE_L10N = False
48 48
49 # If you set this to False, Django will not use timezone-aware datetimes. 49 # If you set this to False, Django will not use timezone-aware datetimes.
50 USE_TZ = False 50 USE_TZ = False
51 51
52 # Absolute filesystem path to the directory that will hold user-uploaded files. 52 # Absolute filesystem path to the directory that will hold user-uploaded files.
53 # Example: "/var/www/example.com/media/" 53 # Example: "/var/www/example.com/media/"
54 MEDIA_ROOT = '' 54 MEDIA_ROOT = ''
55 55
56 # URL that handles the media served from MEDIA_ROOT. Make sure to use a 56 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
57 # trailing slash. 57 # trailing slash.
58 # Examples: "http://example.com/media/", "http://media.example.com/" 58 # Examples: "http://example.com/media/", "http://media.example.com/"
59 MEDIA_URL = '' 59 MEDIA_URL = ''
60 60
61 # Absolute path to the directory static files should be collected to. 61 # Absolute path to the directory static files should be collected to.
62 # Don't put anything in this directory yourself; store your static files 62 # Don't put anything in this directory yourself; store your static files
63 # in apps' "static/" subdirectories and in STATICFILES_DIRS. 63 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
64 # Example: "/var/www/example.com/static/" 64 # Example: "/var/www/example.com/static/"
65 STATIC_ROOT = '' 65 STATIC_ROOT = ''
66 66
67 # URL prefix for static files. 67 # URL prefix for static files.
68 # Example: "http://example.com/static/", "http://static.example.com/" 68 # Example: "http://example.com/static/", "http://static.example.com/"
69 STATIC_URL = '/static/' 69 STATIC_URL = '/static/'
70 70
71 # Additional locations of static files 71 # Additional locations of static files
72 STATICFILES_DIRS = ( 72 STATICFILES_DIRS = (
73 # Put strings here, like "/home/html/static" or "C:/www/django/static". 73 # Put strings here, like "/home/html/static" or "C:/www/django/static".
74 # Always use forward slashes, even on Windows. 74 # Always use forward slashes, even on Windows.
75 # Don't forget to use absolute paths, not relative paths. 75 # Don't forget to use absolute paths, not relative paths.
76 ) 76 )
77 77
78 # List of finder classes that know how to find static files in 78 # List of finder classes that know how to find static files in
79 # various locations. 79 # various locations.
80 STATICFILES_FINDERS = ( 80 STATICFILES_FINDERS = (
81 'django.contrib.staticfiles.finders.FileSystemFinder', 81 'django.contrib.staticfiles.finders.FileSystemFinder',
82 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 82 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
83 # 'django.contrib.staticfiles.finders.DefaultStorageFinder', 83 # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
84 ) 84 )
85 85
86 # Make this unique, and don't share it with anybody. 86 # Make this unique, and don't share it with anybody.
87 SECRET_KEY = 'h6=yzee&jze#4p1@twhksg1wg6hv%pzwomw(!o($qsly%lzlhe' 87 SECRET_KEY = 'h6=yzee&jze#4p1@twhksg1wg6hv%pzwomw(!o($qsly%lzlhe'
88 88
89 # List of callables that know how to import templates from various sources. 89 # List of callables that know how to import templates from various sources.
90 TEMPLATE_LOADERS = ( 90 TEMPLATE_LOADERS = (
91 'django.template.loaders.filesystem.Loader', 91 'django.template.loaders.filesystem.Loader',
92 'django.template.loaders.app_directories.Loader', 92 'django.template.loaders.app_directories.Loader',
93 # 'django.template.loaders.eggs.Loader', 93 # 'django.template.loaders.eggs.Loader',
94 ) 94 )
95 95
96 MIDDLEWARE_CLASSES = ( 96 MIDDLEWARE_CLASSES = (
97 'django.middleware.cache.UpdateCacheMiddleware', # 缓存中间件,必须放在开头
98 'django.middleware.common.CommonMiddleware', 97 'django.middleware.common.CommonMiddleware',
99 'django.contrib.sessions.middleware.SessionMiddleware', 98 'django.contrib.sessions.middleware.SessionMiddleware',
100 'django.middleware.csrf.CsrfViewMiddleware', # 开启了CSRF,记得在POST表单中加{% csrf_token %},使用RequestContext 99 'django.middleware.csrf.CsrfViewMiddleware', # 开启了CSRF,记得在POST表单中加{% csrf_token %},使用RequestContext
101 'django.contrib.auth.middleware.AuthenticationMiddleware', 100 'django.contrib.auth.middleware.AuthenticationMiddleware',
102 'django.contrib.messages.middleware.MessageMiddleware', 101 'django.contrib.messages.middleware.MessageMiddleware',
103 # Uncomment the next line for simple clickjacking protection: 102 # Uncomment the next line for simple clickjacking protection:
104 # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 103 # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
105 'django.middleware.cache.FetchFromCacheMiddleware', # 缓存中间件,必须放在最后 104 'django.middleware.cache.FetchFromCacheMiddleware', # 缓存中间件,必须放在最后
106 ) 105 )
107 106
108 ROOT_URLCONF = 'xp.urls' 107 ROOT_URLCONF = 'xp.urls'
109 108
110 # Python dotted path to the WSGI application used by Django's runserver. 109 # Python dotted path to the WSGI application used by Django's runserver.
111 WSGI_APPLICATION = 'xp.wsgi.application' 110 WSGI_APPLICATION = 'xp.wsgi.application'
112 111
113 TEMPLATE_DIRS = ( 112 TEMPLATE_DIRS = (
114 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". 113 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
115 # Always use forward slashes, even on Windows. 114 # Always use forward slashes, even on Windows.
116 # Don't forget to use absolute paths, not relative paths. 115 # Don't forget to use absolute paths, not relative paths.
117 ) 116 )
118 117
119 TEMPLATE_CONTEXT_PROCESSORS = ( # F2E中有current_user对象和request对象,这里设置可在模板中使用RquestContext 118 TEMPLATE_CONTEXT_PROCESSORS = ( # F2E中有current_user对象和request对象,这里设置可在模板中使用RquestContext
120 'django.contrib.auth.context_processors.auth', # user对象等等 119 'django.contrib.auth.context_processors.auth', # user对象等等
121 'django.core.context_processors.request', # request对象等等 120 'django.core.context_processors.request', # request对象等等
122 'django.core.context_processors.static', # 在模板中使用{{ STATIC_URL }}获取静态文件路径 121 'django.core.context_processors.static', # 在模板中使用{{ STATIC_URL }}获取静态文件路径
123 'forum.context_processors.custom_proc', # 自定义模板上下文处理器 122 'forum.context_processors.custom_proc', # 自定义模板上下文处理器
124 ) 123 )
125 124
126 INSTALLED_APPS = ( 125 INSTALLED_APPS = (
127 'django.contrib.auth', 126 'django.contrib.auth',
128 'django.contrib.contenttypes', 127 'django.contrib.contenttypes',
129 'django.contrib.sessions', 128 'django.contrib.sessions',
130 'django.contrib.sites', 129 'django.contrib.sites',
131 'django.contrib.messages', 130 'django.contrib.messages',
132 'django.contrib.staticfiles', 131 'django.contrib.staticfiles',
133 # Uncomment the next line to enable the admin: 132 # Uncomment the next line to enable the admin:
134 'django.contrib.admin', 133 'django.contrib.admin',
135 # Uncomment the next line to enable admin documentation: 134 # Uncomment the next line to enable admin documentation:
136 # 'django.contrib.admindocs', 135 # 'django.contrib.admindocs',
137 'django.contrib.sitemaps', # Django sitemap framework 136 'django.contrib.sitemaps', # Django sitemap framework
138 'forum', 137 'forum',
139 ) 138 )
140 139
141 # A sample logging configuration. The only tangible logging 140 # A sample logging configuration. The only tangible logging
142 # performed by this configuration is to send an email to 141 # performed by this configuration is to send an email to
143 # the site admins on every HTTP 500 error when DEBUG=False. 142 # the site admins on every HTTP 500 error when DEBUG=False.
144 # See http://docs.djangoproject.com/en/dev/topics/logging for 143 # See http://docs.djangoproject.com/en/dev/topics/logging for
145 # more details on how to customize your logging configuration. 144 # more details on how to customize your logging configuration.
146 LOGGING = { 145 LOGGING = {
147 'version': 1, 146 'version': 1,
148 'disable_existing_loggers': False, 147 'disable_existing_loggers': False,
149 'filters': { 148 'filters': {
150 'require_debug_false': { 149 'require_debug_false': {
151 '()': 'django.utils.log.RequireDebugFalse' 150 '()': 'django.utils.log.RequireDebugFalse'
152 } 151 }
153 }, 152 },
154 'handlers': { 153 'handlers': {
155 'mail_admins': { 154 'mail_admins': {
156 'level': 'ERROR', 155 'level': 'ERROR',
157 'filters': ['require_debug_false'], 156 'filters': ['require_debug_false'],
158 'class': 'django.utils.log.AdminEmailHandler' 157 'class': 'django.utils.log.AdminEmailHandler'
159 }, 158 },
160 'console': { 159 'console': {
161 'level': 'DEBUG', 160 'level': 'DEBUG',
162 'class': 'logging.StreamHandler', 161 'class': 'logging.StreamHandler',
163 }, 162 },
164 }, 163 },
165 'loggers': { 164 'loggers': {
166 'django.request': { 165 'django.request': {
167 'handlers': ['mail_admins'], 166 'handlers': ['mail_admins'],
168 'level': 'ERROR', 167 'level': 'ERROR',
169 'propagate': True, 168 'propagate': True,
170 }, 169 },
171 'django.db.backends': { 170 'django.db.backends': {
172 'level': 'DEBUG', 171 'level': 'DEBUG',
173 'handlers': ['console'], 172 'handlers': ['console'],
174 }, 173 },
175 } 174 }
176 } 175 }
177 # 176 #
178 # CACHES = { # memcached缓存设置 177 # CACHES = { # memcached缓存设置
179 # 'default': { 178 # 'default': {
180 # 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 179 # 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
181 # 'LOCATION': '127.0.0.1:11211', 180 # 'LOCATION': '127.0.0.1:11211',
182 # } 181 # }
183 # } 182 # }
184 183
185 # SESSION_ENGINE = 'django.contrib.sessions.backends.cache' # 使用memcached存储session 184 # SESSION_ENGINE = 'django.contrib.sessions.backends.cache' # 使用memcached存储session
186 185
187 # 自定义User类 186 # 自定义User类
188 AUTH_USER_MODEL = 'forum.ForumUser' 187 AUTH_USER_MODEL = 'forum.ForumUser'
189 188
190 # 用户认证BackEnds 189 # 用户认证BackEnds
191 # AUTHENTICATION_BACKENDS = ('forum.backends.EmailAuthBackend',) 190 # AUTHENTICATION_BACKENDS = ('forum.backends.EmailAuthBackend',)
192 191
193 # 默认登陆uri 192 # 默认登陆uri
194 LOGIN_URL = '/login/' 193 LOGIN_URL = '/login/'
195 194
196 # 发送邮件设置 195 # 发送邮件设置
197 EMAIL_HOST = 'smtp.qq.com' 196 EMAIL_HOST = 'smtp.qq.com'
198 EMAIL_PORT = 25 197 EMAIL_PORT = 25
199 EMAIL_HOST_USER= '*********' 198 EMAIL_HOST_USER= '*********'
200 EMAIL_HOST_PASSWORD= '******' 199 EMAIL_HOST_PASSWORD= '******'
201 DEFAULT_FROM_EMAIL = '*********@qq.com' 200 DEFAULT_FROM_EMAIL = '*********@qq.com'
202 201
203 # 注册用户保留关键字,非Django设置 202 # 注册用户保留关键字,非Django设置
204 RESERVED = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"] 203 RESERVED = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"]
205 204