Commit b6c4f3cc38d842274adf3a3a9501d688fc9f2cf7
1 parent
b9bb6bcb03
Exists in
master
and in
1 other branch
add gunicorn apps
Showing
1 changed file
with
1 additions
and
0 deletions
Show diff stats
xp/settings.py
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.common.CommonMiddleware', | 97 | 'django.middleware.common.CommonMiddleware', |
98 | 'django.contrib.sessions.middleware.SessionMiddleware', | 98 | 'django.contrib.sessions.middleware.SessionMiddleware', |
99 | 'django.middleware.csrf.CsrfViewMiddleware', # 开启了CSRF,记得在POST表单中加{% csrf_token %},使用RequestContext | 99 | 'django.middleware.csrf.CsrfViewMiddleware', # 开启了CSRF,记得在POST表单中加{% csrf_token %},使用RequestContext |
100 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | 100 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
101 | 'django.contrib.messages.middleware.MessageMiddleware', | 101 | 'django.contrib.messages.middleware.MessageMiddleware', |
102 | # Uncomment the next line for simple clickjacking protection: | 102 | # Uncomment the next line for simple clickjacking protection: |
103 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', | 103 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
104 | 'django.middleware.cache.FetchFromCacheMiddleware', # 缓存中间件,必须放在最后 | 104 | 'django.middleware.cache.FetchFromCacheMiddleware', # 缓存中间件,必须放在最后 |
105 | ) | 105 | ) |
106 | 106 | ||
107 | ROOT_URLCONF = 'xp.urls' | 107 | ROOT_URLCONF = 'xp.urls' |
108 | 108 | ||
109 | # 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. |
110 | WSGI_APPLICATION = 'xp.wsgi.application' | 110 | WSGI_APPLICATION = 'xp.wsgi.application' |
111 | 111 | ||
112 | TEMPLATE_DIRS = ( | 112 | TEMPLATE_DIRS = ( |
113 | # 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". |
114 | # Always use forward slashes, even on Windows. | 114 | # Always use forward slashes, even on Windows. |
115 | # Don't forget to use absolute paths, not relative paths. | 115 | # Don't forget to use absolute paths, not relative paths. |
116 | ) | 116 | ) |
117 | 117 | ||
118 | TEMPLATE_CONTEXT_PROCESSORS = ( # F2E中有current_user对象和request对象,这里设置可在模板中使用RquestContext | 118 | TEMPLATE_CONTEXT_PROCESSORS = ( # F2E中有current_user对象和request对象,这里设置可在模板中使用RquestContext |
119 | 'django.contrib.auth.context_processors.auth', # user对象等等 | 119 | 'django.contrib.auth.context_processors.auth', # user对象等等 |
120 | 'django.core.context_processors.request', # request对象等等 | 120 | 'django.core.context_processors.request', # request对象等等 |
121 | 'django.core.context_processors.static', # 在模板中使用{{ STATIC_URL }}获取静态文件路径 | 121 | 'django.core.context_processors.static', # 在模板中使用{{ STATIC_URL }}获取静态文件路径 |
122 | 'forum.context_processors.custom_proc', # 自定义模板上下文处理器 | 122 | 'forum.context_processors.custom_proc', # 自定义模板上下文处理器 |
123 | ) | 123 | ) |
124 | 124 | ||
125 | INSTALLED_APPS = ( | 125 | INSTALLED_APPS = ( |
126 | 'django.contrib.auth', | 126 | 'django.contrib.auth', |
127 | 'django.contrib.contenttypes', | 127 | 'django.contrib.contenttypes', |
128 | 'django.contrib.sessions', | 128 | 'django.contrib.sessions', |
129 | 'django.contrib.sites', | 129 | 'django.contrib.sites', |
130 | 'django.contrib.messages', | 130 | 'django.contrib.messages', |
131 | 'django.contrib.staticfiles', | 131 | 'django.contrib.staticfiles', |
132 | # Uncomment the next line to enable the admin: | 132 | # Uncomment the next line to enable the admin: |
133 | 'django.contrib.admin', | 133 | 'django.contrib.admin', |
134 | # Uncomment the next line to enable admin documentation: | 134 | # Uncomment the next line to enable admin documentation: |
135 | # 'django.contrib.admindocs', | 135 | # 'django.contrib.admindocs', |
136 | 'django.contrib.sitemaps', # Django sitemap framework | 136 | 'django.contrib.sitemaps', # Django sitemap framework |
137 | 'gunicorn', | ||
137 | 'forum', | 138 | 'forum', |
138 | ) | 139 | ) |
139 | 140 | ||
140 | # A sample logging configuration. The only tangible logging | 141 | # A sample logging configuration. The only tangible logging |
141 | # performed by this configuration is to send an email to | 142 | # performed by this configuration is to send an email to |
142 | # the site admins on every HTTP 500 error when DEBUG=False. | 143 | # the site admins on every HTTP 500 error when DEBUG=False. |
143 | # See http://docs.djangoproject.com/en/dev/topics/logging for | 144 | # See http://docs.djangoproject.com/en/dev/topics/logging for |
144 | # more details on how to customize your logging configuration. | 145 | # more details on how to customize your logging configuration. |
145 | LOGGING = { | 146 | LOGGING = { |
146 | 'version': 1, | 147 | 'version': 1, |
147 | 'disable_existing_loggers': False, | 148 | 'disable_existing_loggers': False, |
148 | 'filters': { | 149 | 'filters': { |
149 | 'require_debug_false': { | 150 | 'require_debug_false': { |
150 | '()': 'django.utils.log.RequireDebugFalse' | 151 | '()': 'django.utils.log.RequireDebugFalse' |
151 | } | 152 | } |
152 | }, | 153 | }, |
153 | 'handlers': { | 154 | 'handlers': { |
154 | 'mail_admins': { | 155 | 'mail_admins': { |
155 | 'level': 'ERROR', | 156 | 'level': 'ERROR', |
156 | 'filters': ['require_debug_false'], | 157 | 'filters': ['require_debug_false'], |
157 | 'class': 'django.utils.log.AdminEmailHandler' | 158 | 'class': 'django.utils.log.AdminEmailHandler' |
158 | }, | 159 | }, |
159 | 'console': { | 160 | 'console': { |
160 | 'level': 'DEBUG', | 161 | 'level': 'DEBUG', |
161 | 'class': 'logging.StreamHandler', | 162 | 'class': 'logging.StreamHandler', |
162 | }, | 163 | }, |
163 | }, | 164 | }, |
164 | 'loggers': { | 165 | 'loggers': { |
165 | 'django.request': { | 166 | 'django.request': { |
166 | 'handlers': ['mail_admins'], | 167 | 'handlers': ['mail_admins'], |
167 | 'level': 'ERROR', | 168 | 'level': 'ERROR', |
168 | 'propagate': True, | 169 | 'propagate': True, |
169 | }, | 170 | }, |
170 | 'django.db.backends': { | 171 | 'django.db.backends': { |
171 | 'level': 'DEBUG', | 172 | 'level': 'DEBUG', |
172 | 'handlers': ['console'], | 173 | 'handlers': ['console'], |
173 | }, | 174 | }, |
174 | } | 175 | } |
175 | } | 176 | } |
176 | # | 177 | # |
177 | # CACHES = { # memcached缓存设置 | 178 | # CACHES = { # memcached缓存设置 |
178 | # 'default': { | 179 | # 'default': { |
179 | # 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', | 180 | # 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', |
180 | # 'LOCATION': '127.0.0.1:11211', | 181 | # 'LOCATION': '127.0.0.1:11211', |
181 | # } | 182 | # } |
182 | # } | 183 | # } |
183 | 184 | ||
184 | # SESSION_ENGINE = 'django.contrib.sessions.backends.cache' # 使用memcached存储session | 185 | # SESSION_ENGINE = 'django.contrib.sessions.backends.cache' # 使用memcached存储session |
185 | 186 | ||
186 | # 自定义User类 | 187 | # 自定义User类 |
187 | AUTH_USER_MODEL = 'forum.ForumUser' | 188 | AUTH_USER_MODEL = 'forum.ForumUser' |
188 | 189 | ||
189 | # 用户认证BackEnds | 190 | # 用户认证BackEnds |
190 | # AUTHENTICATION_BACKENDS = ('forum.backends.EmailAuthBackend',) | 191 | # AUTHENTICATION_BACKENDS = ('forum.backends.EmailAuthBackend',) |
191 | 192 | ||
192 | # 默认登陆uri | 193 | # 默认登陆uri |
193 | LOGIN_URL = '/login/' | 194 | LOGIN_URL = '/login/' |
194 | 195 | ||
195 | # 发送邮件设置 | 196 | # 发送邮件设置 |
196 | EMAIL_HOST = 'smtp.qq.com' | 197 | EMAIL_HOST = 'smtp.qq.com' |
197 | EMAIL_PORT = 25 | 198 | EMAIL_PORT = 25 |
198 | EMAIL_HOST_USER= '*********' | 199 | EMAIL_HOST_USER= '*********' |
199 | EMAIL_HOST_PASSWORD= '******' | 200 | EMAIL_HOST_PASSWORD= '******' |
200 | DEFAULT_FROM_EMAIL = '*********@qq.com' | 201 | DEFAULT_FROM_EMAIL = '*********@qq.com' |
201 | 202 | ||
202 | # 注册用户保留关键字,非Django设置 | 203 | # 注册用户保留关键字,非Django设置 |
203 | RESERVED = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"] | 204 | RESERVED = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"] |
204 | 205 |