· 7 years ago · Feb 21, 2018, 05:52 PM
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3
4import os.path
5import sys
6
7# Basic Settings
8PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
9PROJECT_NAME = os.path.split(PROJECT_ROOT)[-1]
10MEDIA_ROOT = '%s/media/' % PROJECT_ROOT
11sys.path.insert(0, os.path.join(PROJECT_ROOT, 'applications'))
12
13# Debug Settings
14DEBUG = False
15TEMPLATE_DEBUG = DEBUG
16
17# Local Settings
18TIME_ZONE = 'Europe/Berlin'
19LANGUAGE_CODE = 'de-de'
20USE_I18N = True
21DEFAULT_CHARSET = 'utf-8'
22
23# Site Settings
24SITE_ID = 1
25ROOT_URLCONF = '%s.urls' % PROJECT_NAME
26APPEND_SLASH = False
27REMOVE_WWW = False
28
29# Middleware
30MIDDLEWARE_CLASSES = (
31 'django.middleware.common.CommonMiddleware',
32 'django.contrib.sessions.middleware.SessionMiddleware',
33 'django.contrib.auth.middleware.AuthenticationMiddleware',
34 'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
35 'django.middleware.doc.XViewMiddleware',
36)
37
38# Template Settings
39TEMPLATE_CONTEXT_PROCESSORS = (
40 # 'lib.context_processors.media_url',
41 # 'lib.context_processors.web_url',
42 # 'lib.context_processors.django_version',
43 'django.core.context_processors.auth',
44 'django.core.context_processors.request',
45)
46
47TEMPLATE_DIRS = (
48 '%s/templates' % PROJECT_ROOT,
49)
50
51TEMPLATE_LOADERS = (
52 'django.template.loaders.filesystem.load_template_source',
53 'django.template.loaders.app_directories.load_template_source',
54)
55
56# Fixture Settings
57FIXTURE_DIRS = (
58 '%s/fixtures' % PROJECT_ROOT,
59)
60
61# Secret Key Generator
62if not hasattr(globals(), 'SECRET_KEY'):
63 SECRET_FILE = os.path.join(PROJECT_ROOT, 'secret.txt')
64 try:
65 SECRET_KEY = open(SECRET_FILE).read().strip()
66 except IOError:
67 try:
68 from random import choice
69 SECRET_KEY = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
70 secret = file(SECRET_FILE, 'w')
71 secret.write(SECRET_KEY)
72 secret.close()
73 except IOError:
74 raise Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE)
75
76
77
78# Import Local settings
79try:
80 from settings_local import *
81except ImportError:
82 try:
83 from mod_python import apache
84 apache.log_error('local_settings.py not set; using default settings', apache.APLOG_NOTICE)
85 except ImportError:
86 import sys
87 sys.stderr.write('local_settings.py not set; using default settings\n')