Last active
August 29, 2015 14:27
-
-
Save dapangmao/4c95d6fd8da0063e2d27 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Django settings for forum project. | |
Generated by 'django-admin startproject' using Django 1.8.2. | |
For more information on this file, see | |
https://docs.djangoproject.com/en/1.8/topics/settings/ | |
For the full list of settings and their values, see | |
https://docs.djangoproject.com/en/1.8/ref/settings/ | |
""" | |
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | |
import os | |
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
# Quick-start development settings - unsuitable for production | |
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ | |
# SECURITY WARNING: keep the secret key used in production secret! | |
SECRET_KEY = '=&n1^+*+wb4e*3=^s#0r(r&c-pr1k2$!azpo6gkgck$4a3wm&a' | |
# SECURITY WARNING: don't run with debug turned on in production! | |
DEBUG = True | |
ALLOWED_HOSTS = [] | |
ADMINS = ( | |
('your name', 'your email address'), | |
) | |
ROOT_URLCONF = 'forum.urls' | |
WSGI_APPLICATION = 'forum.wsgi.application' | |
# Application definition | |
INSTALLED_APPS = ( | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.sites', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'django.contrib.sitemaps', | |
'django.contrib.admin', | |
'django.contrib.admindocs', | |
'django.contrib.humanize', | |
'allauth', | |
'allauth.account', | |
'allauth.socialaccount', | |
'allauth.socialaccount.providers.openid', | |
'allauth.socialaccount.providers.google', | |
'allauth.socialaccount.providers.github', | |
'allauth.socialaccount.providers.twitter', | |
'pagination', | |
'haystack', | |
'django_messages', | |
'djangobb_forum' | |
) | |
MIDDLEWARE_CLASSES = ( | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.common.CommonMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
'django.middleware.security.SecurityMiddleware', | |
'pagination.middleware.PaginationMiddleware', | |
'djangobb_forum.middleware.LastLoginMiddleware', | |
'djangobb_forum.middleware.UsersOnline', | |
'djangobb_forum.middleware.TimezoneMiddleware', | |
) | |
# ROOT_URLCONF = 'forum.urls' | |
TEMPLATE_LOADERS = ( | |
'django.template.loaders.filesystem.Loader', | |
'django.template.loaders.app_directories.Loader', | |
'django.template.loaders.eggs.Loader', | |
) | |
TEMPLATE_DIRS = ( | |
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | |
# Always use forward slashes, even on Windows. | |
# Don't forget to use absolute paths, not relative paths. | |
os.path.join(BASE_DIR, 'templates'), | |
) | |
TEMPLATE_CONTEXT_PROCESSORS = ( | |
'django.contrib.auth.context_processors.auth', | |
'django.core.context_processors.debug', | |
'django.core.context_processors.i18n', | |
'django.core.context_processors.media', | |
'django.core.context_processors.static', | |
'django.core.context_processors.request', | |
'django.contrib.messages.context_processors.messages', | |
'django_messages.context_processors.inbox', | |
'allauth.account.context_processors.account', | |
'allauth.socialaccount.context_processors.socialaccount', | |
'djangobb_forum.context_processors.forum_settings', | |
) | |
TEMPLATES = [ | |
{ | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': TEMPLATE_DIRS, | |
'OPTIONS': { | |
'context_processors': TEMPLATE_CONTEXT_PROCESSORS, | |
'loaders': TEMPLATE_LOADERS, | |
}, | |
}, | |
] | |
# WSGI_APPLICATION = 'forum.wsgi.application' | |
# Database | |
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | |
'NAME': 'bb', # Or path to database file if using sqlite3. | |
'USER': 'root', # Not used with sqlite3. | |
'PASSWORD': '800823', # Not used with sqlite3. | |
'HOST': '', # Set to empty string for localhost. Not used with sqlite3. | |
'PORT': '5432', # Set to empty string for default. Not used with sqlite3. | |
} | |
} | |
# Internationalization | |
# https://docs.djangoproject.com/en/1.8/topics/i18n/ | |
LANGUAGE_CODE = 'zh-CN' | |
TIME_ZONE = 'UTC' | |
USE_I18N = True | |
USE_L10N = True | |
USE_TZ = True | |
SITE_ID = 1 | |
# Static files (CSS, JavaScript, Images) | |
# https://docs.djangoproject.com/en/1.8/howto/static-files/ | |
STATIC_URL = '/static/' | |
STATIC_ROOT = '' | |
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | |
MEDIA_URL = '/media/' | |
HAYSTACK_CONNECTIONS = { | |
'default': { | |
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', | |
'PATH': os.path.join(BASE_DIR, 'djangobb_index'), | |
'INCLUDE_SPELLING': True, | |
}, | |
} | |
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' | |
# Account settings | |
ACCOUNT_ACTIVATION_DAYS = 7 | |
LOGIN_REDIRECT_URL = '/forum/' | |
LOGIN_URL = '/forum/account/signin/' | |
AUTHENTICATION_BACKENDS = ( | |
'django.contrib.auth.backends.ModelBackend', | |
'allauth.account.auth_backends.AuthenticationBackend', | |
) | |
# Allauth | |
ACCOUNT_LOGOUT_ON_GET = True | |
ACCOUNT_EMAIL_REQUIRED = True | |
ACCOUNT_SIGNUP_FORM_CLASS = 'forms.SignupForm' | |
try: | |
import mailer | |
INSTALLED_APPS += ('mailer',) | |
EMAIL_BACKEND = "mailer.backend.DbBackend" | |
except ImportError: | |
pass | |
try: | |
from local_settings import * | |
except ImportError: | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os.path | |
PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__)) | |
DEBUG = True | |
TEMPLATE_DEBUG = DEBUG | |
ADMINS = ( | |
# ('admin', '[email protected]'), | |
) | |
MANAGERS = ADMINS | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | |
'NAME': 'bb', # Or path to database file if using sqlite3. | |
'USER': 'root', # Not used with sqlite3. | |
'PASSWORD': '800823', # Not used with sqlite3. | |
'HOST': '', # Set to empty string for localhost. Not used with sqlite3. | |
'PORT': '5432', # Set to empty string for default. Not used with sqlite3. | |
} | |
} | |
# Local time zone for this installation. Choices can be found here: | |
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | |
# although not all choices may be available on all operating systems. | |
# If running in a Windows environment this must be set to the same as your | |
# system time zone. | |
TIME_ZONE = 'UTC' | |
USE_TZ = True | |
# Language code for this installation. All choices can be found here: | |
# http://www.i18nguy.com/unicode/language-identifiers.html | |
LANGUAGE_CODE = 'zh_CN' | |
LANGUAGES = ( | |
('ca', 'Catalan'), | |
('cs', 'Czech'), | |
('de', 'German'), | |
('en', 'English'), | |
('es', 'Spanish'), | |
('fo', 'Faroese'), | |
('fr', 'France'), | |
('it', 'Italian'), | |
('lt', 'Lithuanian'), | |
('mn', 'Mongolian'), | |
('nl', 'Dutch'), | |
('pl', 'Polish'), | |
('ru', 'Russian'), | |
('uk_UA', 'Ukrainian'), | |
('vi', 'Vietnamese'), | |
('zh_CN', 'Chinese'), | |
) | |
SITE_ID = 1 | |
# If you set this to False, Django will make some optimizations so as not | |
# to load the internationalization machinery. | |
USE_I18N = True | |
# If you set this to False, Django will not format dates, numbers and | |
# calendars according to the current locale | |
USE_L10N = True | |
# Absolute filesystem path to the directory that will hold user-uploaded files. | |
# Example: "/home/media/media.lawrence.com/media/" | |
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media') | |
# URL that handles the media served from MEDIA_ROOT. Make sure to use a | |
# trailing slash. | |
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/" | |
MEDIA_URL = '/media/' | |
# Absolute path to the directory static files should be collected to. | |
# Don't put anything in this directory yourself; store your static files | |
# in apps' "static/" subdirectories and in STATICFILES_DIRS. | |
# Example: "/home/media/media.lawrence.com/static/" | |
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') | |
# URL prefix for static files. | |
# Example: "http://media.lawrence.com/static/" | |
STATIC_URL = '/static/' | |
# Additional locations of static files | |
STATICFILES_DIRS = ( | |
os.path.join(PROJECT_ROOT,'project_static'), | |
) | |
# List of finder classes that know how to find static files in | |
# various locations. | |
STATICFILES_FINDERS = ( | |
'django.contrib.staticfiles.finders.FileSystemFinder', | |
'django.contrib.staticfiles.finders.AppDirectoriesFinder', | |
# 'django.contrib.staticfiles.finders.DefaultStorageFinder', | |
) | |
# Make this unique, and don't share it with anybody. | |
if not hasattr(globals(), 'SECRET_KEY'): | |
SECRET_FILE = os.path.join(PROJECT_ROOT, 'secret.txt') | |
try: | |
SECRET_KEY = open(SECRET_FILE).read().strip() | |
except IOError: | |
try: | |
from random import choice | |
import string | |
symbols = ''.join((string.lowercase, string.digits, string.punctuation )) | |
SECRET_KEY = ''.join([choice(symbols) for i in range(50)]) | |
secret = file(SECRET_FILE, 'w') | |
secret.write(SECRET_KEY) | |
secret.close() | |
except IOError: | |
raise Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE) | |
MIDDLEWARE_CLASSES = ( | |
'django.middleware.cache.UpdateCacheMiddleware', | |
'django.middleware.common.CommonMiddleware', | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.locale.LocaleMiddleware', | |
'pagination.middleware.PaginationMiddleware', | |
'django.middleware.cache.FetchFromCacheMiddleware', | |
'djangobb_forum.middleware.LastLoginMiddleware', | |
'djangobb_forum.middleware.UsersOnline', | |
'djangobb_forum.middleware.TimezoneMiddleware', | |
) | |
ROOT_URLCONF = 'urls' | |
TEMPLATE_LOADERS = ( | |
'django.template.loaders.filesystem.Loader', | |
'django.template.loaders.app_directories.Loader', | |
'django.template.loaders.eggs.Loader', | |
) | |
TEMPLATE_DIRS = ( | |
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | |
# Always use forward slashes, even on Windows. | |
# Don't forget to use absolute paths, not relative paths. | |
os.path.join(PROJECT_ROOT, 'templates'), | |
) | |
TEMPLATE_CONTEXT_PROCESSORS = ( | |
'django.contrib.auth.context_processors.auth', | |
'django.core.context_processors.debug', | |
'django.core.context_processors.i18n', | |
'django.core.context_processors.media', | |
'django.core.context_processors.static', | |
'django.core.context_processors.request', | |
'django.contrib.messages.context_processors.messages', | |
'django_messages.context_processors.inbox', | |
'allauth.account.context_processors.account', | |
'allauth.socialaccount.context_processors.socialaccount', | |
'djangobb_forum.context_processors.forum_settings', | |
) | |
TEMPLATES = [ | |
{ | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': TEMPLATE_DIRS, | |
'OPTIONS': { | |
'context_processors': TEMPLATE_CONTEXT_PROCESSORS, | |
'loaders': TEMPLATE_LOADERS, | |
}, | |
}, | |
] | |
INSTALLED_APPS = ( | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.sites', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'django.contrib.sitemaps', | |
'django.contrib.admin', | |
'django.contrib.admindocs', | |
'django.contrib.humanize', | |
'allauth', | |
'allauth.account', | |
'allauth.socialaccount', | |
'allauth.socialaccount.providers.openid', | |
'allauth.socialaccount.providers.google', | |
'allauth.socialaccount.providers.github', | |
'allauth.socialaccount.providers.twitter', | |
'pagination', | |
'haystack', | |
'django_messages', | |
'nocaptcha_recaptcha', | |
'djangobb_forum', | |
) | |
# A sample logging configuration. The only tangible logging | |
# performed by this configuration is to send an email to | |
# the site admins on every HTTP 500 error when DEBUG=False. | |
# See http://docs.djangoproject.com/en/dev/topics/logging for | |
# more details on how to customize your logging configuration. | |
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'filters': { | |
'require_debug_false': { | |
'()': 'django.utils.log.RequireDebugFalse' | |
} | |
}, | |
'handlers': { | |
'mail_admins': { | |
'level': 'ERROR', | |
'filters': ['require_debug_false'], | |
'class': 'django.utils.log.AdminEmailHandler' | |
} | |
}, | |
'loggers': { | |
'django.request': { | |
'handlers': ['mail_admins'], | |
'level': 'ERROR', | |
'propagate': True, | |
}, | |
} | |
} | |
try: | |
import mailer | |
INSTALLED_APPS += ('mailer',) | |
EMAIL_BACKEND = "mailer.backend.DbBackend" | |
except ImportError: | |
pass | |
try: | |
import south | |
INSTALLED_APPS += ('south',) | |
SOUTH_TESTS_MIGRATE = False | |
except ImportError: | |
pass | |
FORCE_SCRIPT_NAME = '' | |
# Haystack settings | |
HAYSTACK_CONNECTIONS = { | |
'default': { | |
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', | |
'PATH': os.path.join(PROJECT_ROOT, 'djangobb_index'), | |
'INCLUDE_SPELLING': True, | |
}, | |
} | |
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' | |
# Account settings | |
ACCOUNT_ACTIVATION_DAYS = 10 | |
LOGIN_REDIRECT_URL = '/forum/' | |
LOGIN_URL = '/forum/account/signin/' | |
AUTHENTICATION_BACKENDS = ( | |
'django.contrib.auth.backends.ModelBackend', | |
'allauth.account.auth_backends.AuthenticationBackend', | |
) | |
# Cache settings | |
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True | |
# Allauth | |
ACCOUNT_LOGOUT_ON_GET = True | |
ACCOUNT_EMAIL_REQUIRED = True | |
ACCOUNT_SIGNUP_FORM_CLASS = 'forms.SignupForm' | |
try: | |
from local_settings import * | |
except ImportError: | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls import * | |
from django.conf import settings | |
from django.contrib import admin | |
from django.conf.urls.static import static | |
from djangobb_forum import settings as forum_settings | |
from djangobb_forum.sitemap import SitemapForum, SitemapTopic | |
sitemaps = { | |
'forum': SitemapForum, | |
'topic': SitemapTopic, | |
} | |
urlpatterns = patterns('', | |
# Admin | |
url(r'^admin/', include(admin.site.urls)), | |
# Sitemap | |
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}), | |
# Apps | |
url(r'^forum/account/', include('allauth.urls')), | |
url(r'^forum/', include('djangobb_forum.urls', namespace='djangobb')), | |
) | |
# PM Extension | |
if (forum_settings.PM_SUPPORT): | |
urlpatterns += patterns('', | |
url(r'^forum/pm/', include('django_messages.urls')), | |
) | |
if (settings.DEBUG): | |
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment