1
- import os # isort:skip
2
- gettext = lambda s : s
3
- DATA_DIR = os .path .dirname (os .path .dirname (__file__ ))
4
1
"""
5
2
Django settings for gsoc project.
6
3
13
10
https://docs.djangoproject.com/en/1.11/ref/settings/
14
11
"""
15
12
13
+ import logging .config
16
14
import os
17
15
16
+
17
+ gettext = lambda s : s
18
+ DATA_DIR = os .path .dirname (os .path .dirname (__file__ ))
18
19
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
19
20
BASE_DIR = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
20
21
29
30
DEBUG = True
30
31
31
32
ALLOWED_HOSTS = ['*' ]
33
+ INTERNAL_IPS = ('127.0.0.1' ,)
32
34
35
+ # EMAIL CONFIGURATION
36
+ # ------------------------------------------------------------------------------
37
+ # See: https://docs.djangoproject.com/en/2.1/ref/settings/#email
38
+ # TODO: Update it with real settings
39
+ ADMINS = [(
'Admin 1' ,
'[email protected] ' )]
33
40
34
- # Application definition
35
-
36
-
41
+ if DEBUG :
42
+ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
43
+ else :
44
+ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
37
45
46
+ DEFAULT_FROM_EMAIL = '[email protected] '
47
+ EMAIL_SUBJECT_PREFIX = '[Python-GSoC]'
48
+ EMAIL_USE_TLS = True
49
+ SERVER_EMAIL = DEFAULT_FROM_EMAIL
50
+ EMAIL_HOST = 'smtp.gmail.com'
51
+ EMAIL_PORT = 587
52
+ EMAIL_HOST_USER = "[email protected] "
53
+ EMAIL_HOST_PASSWORD = "supersecretpassword"
38
54
39
55
56
+ # Application definition
40
57
ROOT_URLCONF = 'gsoc.urls'
41
58
42
-
43
-
44
-
45
59
# Internationalization
46
60
# https://docs.djangoproject.com/en/1.11/topics/i18n/
47
61
55
69
56
70
USE_TZ = True
57
71
58
-
59
72
# Static files (CSS, JavaScript, Images)
60
73
# https://docs.djangoproject.com/en/1.11/howto/static-files/
61
74
69
82
)
70
83
SITE_ID = 1
71
84
72
-
73
85
TEMPLATES = [
74
86
{
75
87
'BACKEND' : 'django.template.backends.django.DjangoTemplates' ,
96
108
},
97
109
]
98
110
99
-
100
111
MIDDLEWARE = (
101
112
'debug_toolbar.middleware.DebugToolbarMiddleware' ,
102
113
'cms.middleware.utils.ApphookReloadMiddleware' ,
257
268
258
269
# AUTH_USER_MODEL = 'gsoc.User'
259
270
260
-
261
-
262
- INTERNAL_IPS = ('127.0.0.1' ,)
271
+ # LOGGING CONFIGURATION
272
+ # ------------------------------------------------------------------------------
273
+ # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
274
+ # See: http://docs.djangoproject.com/en/dev/topics/logging
275
+ # See: https://docs.djangoproject.com/en/2.1/topics/logging/#disabling-logging-configuration
276
+ LOGGING_CONFIG = None
277
+
278
+ if DEBUG :
279
+ ERROR_LEVEL = 'DEBUG'
280
+ else :
281
+ ERROR_LEVEL = 'INFO'
282
+
283
+ ERROR_HANDLERS = ['file' , 'mail_admins' ]
284
+
285
+ LOGGING = {
286
+ 'version' : 1 ,
287
+ 'disable_existing_loggers' : False ,
288
+ 'formatters' : {
289
+ 'verbose' : {
290
+ 'format' : ('%(levelname)s %(asctime)s %(process)d '
291
+ '%(thread)d %(filename)s %(module)s %(funcName)s '
292
+ '%(lineno)d %(message)s' )
293
+ },
294
+ 'simple' : {
295
+ 'format' : '%(levelname)s: %(message)s'
296
+ },
297
+ },
298
+ 'filters' : {
299
+ 'require_debug_false' : {
300
+ '()' : 'django.utils.log.RequireDebugFalse'
301
+ }
302
+ },
303
+ 'handlers' : {
304
+ 'console' : {
305
+ 'level' : 'DEBUG' ,
306
+ 'class' : 'logging.StreamHandler' ,
307
+ 'formatter' : 'verbose'
308
+ },
309
+ 'file' : {
310
+ 'level' : 'DEBUG' ,
311
+ 'class' : 'logging.handlers.TimedRotatingFileHandler' ,
312
+ 'filename' : os .path .join (BASE_DIR , 'logs/pygsoc.log' ),
313
+ 'formatter' : 'verbose' ,
314
+ 'when' : 'midnight' ,
315
+ 'backupCount' : 60 ,
316
+ 'encoding' : 'utf-8' ,
317
+ },
318
+ 'access_logs' : {
319
+ 'level' : 'INFO' ,
320
+ 'class' : 'logging.handlers.TimedRotatingFileHandler' ,
321
+ 'filename' : os .path .join (BASE_DIR , 'logs/access.log' ),
322
+ 'formatter' : 'simple' ,
323
+ 'when' : 'midnight' ,
324
+ 'backupCount' : 7 ,
325
+ 'encoding' : 'utf-8' ,
326
+ },
327
+ 'mail_admins' : {
328
+ 'level' : 'ERROR' ,
329
+ 'class' : 'django.utils.log.AdminEmailHandler'
330
+ },
331
+ },
332
+ 'loggers' : {
333
+ 'django' : {
334
+ 'handlers' : ['file' ],
335
+ 'level' : 'INFO' ,
336
+ 'propagate' : True ,
337
+ },
338
+ 'django.server' : {
339
+ 'handlers' : ['console' ],
340
+ 'level' : 'DEBUG' ,
341
+ 'propagate' : False ,
342
+ },
343
+ 'django.db' : {
344
+ 'handlers' : ['file' ],
345
+ 'level' : 'WARNING' ,
346
+ 'propagate' : False ,
347
+ },
348
+ 'django.security.DisallowedHost' : {
349
+ 'handlers' : ['file' ],
350
+ 'propagate' : False ,
351
+ },
352
+ # Catch All Logger -- Captures any other logging
353
+ '' : {
354
+ 'handlers' : ERROR_HANDLERS ,
355
+ 'level' : ERROR_LEVEL ,
356
+ }
357
+ }
358
+ }
359
+ logging .config .dictConfig (LOGGING )
263
360
264
361
# Runcron settings
265
362
296
393
'toolbarCanCollapse' : False ,
297
394
}
298
395
299
- TEXT_ADDITIONAL_TAGS = ('iframe' ,)
396
+ TEXT_ADDITIONAL_TAGS = ('iframe' ,)
0 commit comments