source: mauRepo/dj_security/trunk/dj_security/settings.py @ 8687

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/dj_security/trunk/dj_security/settings.py@8687
Revision 8687, 7.4 KB checked in by mnagni, 7 years ago (diff)

Small improves to logging

  • Property svn:mime-type set to text/plain
Line 
1# Django settings for mydjango_secapp project.
2import os
3
4
5def decode_relative_path(rel_path):
6    return os.path.join(os.path.dirname(__file__), rel_path).replace('\\', '/') 
7
8DEBUG = True
9TEMPLATE_DEBUG = DEBUG
10
11ADMINS = (
12    # ('Your Name', 'your_email@example.com'),
13)
14MANAGERS = ADMINS
15
16"""
17DATABASES = {
18    'default': {
19        'ENGINE': 'django.db.backends.sqlite3',                 
20        'NAME': decode_relative_path('.') + '/sqlite.db',
21        'USER': '',                   
22        'PASSWORD': '',                     
23        'HOST': '',                     
24        'PORT': '',
25    }
26}
27"""
28
29DATABASES = {
30    # This parameters are usually set during
31    # the deployment configuration process
32    'default': {
33        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.               
34        'ENGINE': 'DB_ENGINE',
35        # Or path to database file if using sqlite3.
36        'NAME': 'DB_NAME',
37        # Not used with sqlite3.                     
38        'USER': 'DB_USER',
39        # Not used with sqlite3.                     
40        'PASSWORD': 'DB_PASSWORD',
41        # Set to empty string for localhost. Not used with sqlite3.       
42        'HOST': 'DB_HOST',                     
43        # Set to empty string for default. Not used with sqlite3.       
44        'PORT': 'DB_PORT',                     
45    }
46}
47
48# Local time zone for this installation. Choices can be found here:
49# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
50# although not all choices may be available on all operating systems.
51# In a Windows environment this must be set to your system time zone.
52TIME_ZONE = 'America/Chicago'
53
54# Language code for this installation. All choices can be found here:
55# http://www.i18nguy.com/unicode/language-identifiers.html
56LANGUAGE_CODE = 'en-us'
57
58SITE_ID = 1
59
60# If you set this to False, Django will make some optimizations so as not
61# to load the internationalization machinery.
62USE_I18N = True
63
64# If you set this to False, Django will not format dates, numbers and
65# calendars according to the current locale.
66USE_L10N = True
67
68# If you set this to False, Django will not use timezone-aware datetimes.
69USE_TZ = True
70
71# Absolute filesystem path to the directory that will hold user-uploaded files.
72# Example: "/home/media/media.lawrence.com/media/"
73MEDIA_ROOT = ''
74
75# URL that handles the media served from MEDIA_ROOT. Make sure to use a
76# trailing slash.
77# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
78MEDIA_URL = ''
79
80# Absolute path to the directory static files should be collected to.
81# Don't put anything in this directory yourself; store your static files
82# in apps' "static/" subdirectories and in STATICFILES_DIRS.
83# Example: "/home/media/media.lawrence.com/static/"
84STATIC_ROOT = ''
85
86# URL prefix for static files.
87# Example: "http://media.lawrence.com/static/"
88STATIC_URL = '/static/'
89
90# Additional locations of static files
91STATICFILES_DIRS = (
92    # Put strings here, like "/home/html/static" or "C:/www/django/static".
93    # Always use forward slashes, even on Windows.
94    # Don't forget to use absolute paths, not relative paths.
95)
96
97# List of finder classes that know how to find static files in
98# various locations.
99STATICFILES_FINDERS = (
100    'django.contrib.staticfiles.finders.FileSystemFinder',
101    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
102#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
103)
104
105# Make this unique, and don't share it with anybody.
106SECRET_KEY = '=+l)#o$ugq4pc14*$08q5gw(&0@nns@gm&2f=bx0_*jc1+y%w1'
107
108# List of callables that know how to import templates from various sources.
109TEMPLATE_LOADERS = (
110    'django.template.loaders.filesystem.Loader',
111    'django.template.loaders.app_directories.Loader',
112#     'django.template.loaders.eggs.Loader',
113)
114
115MIDDLEWARE_CLASSES = (
116    'django.middleware.common.CommonMiddleware',
117    'django.contrib.sessions.middleware.SessionMiddleware',
118    'django.middleware.csrf.CsrfViewMiddleware',
119    'django.contrib.auth.middleware.AuthenticationMiddleware',
120    'django.contrib.messages.middleware.MessageMiddleware',
121    #'django_authopenid.middleware.OpenIDMiddleware',
122    'dj_security.middleware.DJ_Security_Middleware',
123    # Uncomment the next line for simple clickjacking protection:
124    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
125)
126
127ROOT_URLCONF = 'dj_security.urls'
128
129# Python dotted path to the WSGI application used by Django's runserver.
130#WSGI_APPLICATION = 'dj_security.wsgi.application'
131
132TEMPLATE_DIRS = (
133    decode_relative_path('static/templates')
134    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
135    # Always use forward slashes, even on Windows.
136    # Don't forget to use absolute paths, not relative paths.
137)
138
139INSTALLED_APPS = (
140    'django.contrib.auth',
141    'django.contrib.contenttypes',
142    'django.contrib.sessions',
143    'django.contrib.sites',
144    'django.contrib.messages',
145    'django.contrib.staticfiles',
146    'registration',
147    'django.contrib.humanize',
148    #'django_authopenid',
149    'dj_security',
150    # Uncomment the next line to enable the admin:
151    # 'django.contrib.admin',
152    # Uncomment the next line to enable admin documentation:
153    # 'django.contrib.admindocs',
154)
155
156NOT_ENCODE = ['password', 'backend']
157SHARED_SECRET = 'sharedsecret'   
158APPLICATION_ROOT = 'PROJECT_NAME_PAR/'
159if APPLICATION_ROOT.startswith('PROJECT_NAME_'):
160    APPLICATION_ROOT = ''
161   
162# One-week activation window; you may, of course, use a different value.   
163ACCOUNT_ACTIVATION_DAYS = 7
164
165# Adds to the site framework the current machine
166# where dj_security is deployed
167import socket
168try:
169    HOSTNAME = socket.gethostname()
170except Exception:
171    HOSTNAME = 'localhost'
172from django.contrib.sites.models import Site
173from django.db.utils import DatabaseError   
174try:
175    site = Site()
176    site.name = HOSTNAME
177    site.domain = HOSTNAME + '/' + APPLICATION_ROOT
178    site.save()
179    #Sets the default site
180    SITE_ID = site.pk
181except DatabaseError as ex:
182    print str(ex)
183
184
185
186TEMPLATE_CONTEXT_PROCESSORS = (
187    'django_authopenid.context_processors.authopenid',
188    'django.core.context_processors.i18n',
189)
190
191AUTH_PROFILE_MODULE = 'dj_security.UserProfile'
192
193# A sample logging configuration. The only tangible logging
194# performed by this configuration is to send an email to
195# the site admins on every HTTP 500 error when DEBUG=False.
196# See http://docs.djangoproject.com/en/dev/topics/logging for
197# more details on how to customize your logging configuration.
198LOGGING = {
199    'version': 1,
200    'disable_existing_loggers': False,
201    'formatters': {
202        'verbose': {
203            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
204        },
205        'simple': {
206            'format': '%(levelname)s %(message)s'
207        },
208    },
209    'filters': {
210        'require_debug_false': {
211            '()': 'django.utils.log.RequireDebugFalse'
212        }
213    },
214    'handlers': {
215        'mail_admins': {
216            'level': 'ERROR',
217            'filters': ['require_debug_false'],
218            'class': 'django.utils.log.AdminEmailHandler'
219        },
220        'console':{
221            'level':'DEBUG',
222            'class':'logging.StreamHandler',
223            'formatter': 'verbose'
224        }
225    },
226    'loggers': {
227        'django.request': {
228            'handlers': ['mail_admins'],
229            'level': 'ERROR',
230            'propagate': True,
231        },
232        'dj_security': {
233            'handlers': ['console'],
234            'level': 'DEBUG',
235            'propagate': True,
236        }
237    }
238}
Note: See TracBrowser for help on using the repository browser.