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

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

FIxes uncorrect context_processor definition

  • 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    # Uncomment the next line for simple clickjacking protection:
123    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
124)
125
126ROOT_URLCONF = 'dj_security.urls'
127
128# Python dotted path to the WSGI application used by Django's runserver.
129#WSGI_APPLICATION = 'dj_security.wsgi.application'
130
131TEMPLATE_DIRS = (
132    decode_relative_path('static/templates')
133    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
134    # Always use forward slashes, even on Windows.
135    # Don't forget to use absolute paths, not relative paths.
136)
137
138INSTALLED_APPS = (
139    'django.contrib.auth',
140    'django.contrib.contenttypes',
141    'django.contrib.sessions',
142    'django.contrib.sites',
143    'django.contrib.messages',
144    'django.contrib.staticfiles',
145    'registration',
146    'django.contrib.humanize',
147    'django_authopenid',
148    'dj_security',
149    # Uncomment the next line to enable the admin:
150    # 'django.contrib.admin',
151    # Uncomment the next line to enable admin documentation:
152    # 'django.contrib.admindocs',
153)
154
155SHARED_SECRET = 'sharedsecret'   
156APPLICATION_ROOT = 'PROJECT_NAME_PAR/'
157if APPLICATION_ROOT.startswith('PROJECT_NAME_'):
158    APPLICATION_ROOT = ''
159   
160# One-week activation window; you may, of course, use a different value.   
161ACCOUNT_ACTIVATION_DAYS = 7
162
163# Adds to the site framework the current machine
164# where dj_security is deployed
165import socket
166try:
167    HOSTNAME = socket.gethostname()
168except Exception:
169    HOSTNAME = 'localhost'
170from django.contrib.sites.models import Site
171from django.db.utils import DatabaseError   
172try:
173    site = Site()
174    site.name = HOSTNAME
175    site.domain = HOSTNAME + '/' + APPLICATION_ROOT
176    site.save()
177    #Sets the default site
178    SITE_ID = site.pk
179except DatabaseError as ex:
180    print str(ex)
181
182
183
184TEMPLATE_CONTEXT_PROCESSORS = (
185    'django_authopenid.context_processors.authopenid',
186    'django.core.context_processors.i18n',
187)
188
189AUTH_PROFILE_MODULE = 'dj_security.UserProfile'
190
191# A sample logging configuration. The only tangible logging
192# performed by this configuration is to send an email to
193# the site admins on every HTTP 500 error when DEBUG=False.
194# See http://docs.djangoproject.com/en/dev/topics/logging for
195# more details on how to customize your logging configuration.
196LOGGING = {
197    'version': 1,
198    'disable_existing_loggers': False,
199    'filters': {
200        'require_debug_false': {
201            '()': 'django.utils.log.RequireDebugFalse'
202        }
203    },
204    'handlers': {
205        'mail_admins': {
206            'level': 'ERROR',
207            'filters': ['require_debug_false'],
208            'class': 'django.utils.log.AdminEmailHandler'
209        }
210    },
211    'loggers': {
212        'django.request': {
213            'handlers': ['mail_admins'],
214            'level': 'ERROR',
215            'propagate': True,
216        },
217    }
218}
Note: See TracBrowser for help on using the repository browser.