snipt/settings.py

257 lines
6.9 KiB
Python
Raw Normal View History

2011-10-23 17:54:44 -07:00
# Django settings for sidepros project.
2011-06-01 21:50:18 -07:00
2011-10-23 20:07:59 -07:00
import os, socket
2011-10-23 17:54:44 -07:00
2011-11-09 08:20:45 -08:00
if socket.gethostname() in ['nickmba.local', 'nickimac.local']:
2011-12-22 19:23:50 -08:00
DEBUG = True
2011-10-23 20:07:59 -07:00
else:
2011-12-04 17:23:44 -08:00
DEBUG = False
2011-10-23 17:54:44 -07:00
TEMPLATE_DEBUG = DEBUG
2011-10-23 19:44:37 -07:00
BASE_PATH = os.path.dirname(__file__)
2011-06-01 21:50:18 -07:00
ADMINS = (
('Nick Sergeant', 'nick@snipt.net'),
)
2011-12-04 17:45:34 -08:00
MANAGERS = ADMINS
2011-06-01 21:50:18 -07:00
INTERNAL_IPS = ('127.0.0.1',)
2012-03-17 09:05:40 -07:00
if DEBUG:
DB_USER = 'Nick'
else:
DB_USER = 'nick'
2011-10-23 17:54:44 -07:00
DATABASES = {
'default': {
2012-02-14 18:09:39 -08:00
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'snipt',
2012-03-17 09:05:40 -07:00
'USER': DB_USER,
2011-10-23 17:54:44 -07:00
'PASSWORD': '',
2012-02-14 18:09:39 -08:00
'HOST': 'localhost',
2011-10-23 17:54:44 -07:00
'PORT': '',
}
}
# 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.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
2011-06-01 21:50:18 -07:00
TIME_ZONE = 'America/New_York'
2011-10-23 17:54:44 -07:00
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
2011-06-01 21:50:18 -07:00
LANGUAGE_CODE = 'en-us'
2011-10-23 17:54:44 -07:00
2011-06-01 21:50:18 -07:00
SITE_ID = 1
2011-10-23 17:54:44 -07:00
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
2011-06-01 21:50:18 -07:00
2011-10-23 17:54:44 -07:00
# 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/"
2011-12-25 13:00:41 -08:00
MEDIA_ROOT = os.path.join(BASE_PATH, 'media/uploads')
2011-10-23 17:54:44 -07:00
# 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/"
2011-12-25 13:00:41 -08:00
MEDIA_URL = '/media/uploads/'
2011-10-23 17:54:44 -07:00
# 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/"
2011-10-23 19:44:37 -07:00
STATIC_ROOT = os.path.join(BASE_PATH, 'static')
2012-03-05 10:05:53 -08:00
if DEBUG:
STATIC_URL = '/media/'
else:
STATIC_URL = '/static/'
2011-10-23 17:54:44 -07:00
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
2012-03-05 09:57:39 -08:00
ADMIN_MEDIA_PREFIX = '/static/grappelli/'
2011-10-23 17:54:44 -07:00
# Additional locations of static files
STATICFILES_DIRS = (
2011-10-23 19:44:37 -07:00
os.path.join(BASE_PATH, 'media'),
2011-10-23 17:54:44 -07:00
)
2011-06-01 21:50:18 -07:00
2011-10-23 17:54:44 -07:00
# 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',
2012-03-05 13:38:37 -08:00
'compressor.finders.CompressorFinder',
2011-06-01 21:50:18 -07:00
)
2011-10-23 17:54:44 -07:00
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'afk&6t4l#x+9hhhpl2&3zm&me06fcu&v3*j54kxitbe8kg-19)'
# List of callables that know how to import templates from various sources.
2011-06-01 21:50:18 -07:00
TEMPLATE_LOADERS = (
2011-10-23 17:54:44 -07:00
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
2011-06-01 21:50:18 -07:00
)
2011-10-23 19:44:37 -07:00
TEMPLATE_CONTEXT_PROCESSORS = (
2012-06-04 13:22:00 -07:00
'django.contrib.auth.context_processors.auth',
2011-10-23 19:44:37 -07:00
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.core.context_processors.static',
)
2011-10-23 17:54:44 -07:00
2011-06-01 21:50:18 -07:00
MIDDLEWARE_CLASSES = (
2012-06-04 13:50:29 -07:00
'blogs.middleware.BlogMiddleware',
2012-06-04 13:22:00 -07:00
'django.middleware.csrf.CsrfViewMiddleware',
2011-06-01 21:50:18 -07:00
'django.middleware.common.CommonMiddleware',
2011-10-23 17:54:44 -07:00
'django.contrib.sessions.middleware.SessionMiddleware',
2011-06-01 21:50:18 -07:00
'django.contrib.auth.middleware.AuthenticationMiddleware',
2011-10-23 17:54:44 -07:00
'django.contrib.messages.middleware.MessageMiddleware',
2011-10-12 08:29:21 -07:00
'pagination.middleware.PaginationMiddleware',
2011-06-01 21:50:18 -07:00
)
2011-10-23 17:54:44 -07:00
ROOT_URLCONF = 'snipt.urls'
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
2011-06-01 21:50:18 -07:00
2011-10-23 17:54:44 -07:00
TEMPLATE_DIRS = (
os.path.join(PROJECT_PATH, 'templates')
)
2011-06-01 21:50:18 -07:00
INSTALLED_APPS = (
2011-10-23 17:54:44 -07:00
'gunicorn',
2011-06-01 21:50:18 -07:00
'grappelli',
2012-02-12 17:17:17 -08:00
2011-06-01 21:50:18 -07:00
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.humanize',
'django.contrib.sessions',
'django.contrib.sites',
2011-10-23 17:54:44 -07:00
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
2011-06-01 21:50:18 -07:00
2012-03-05 13:38:37 -08:00
'compressor',
2011-06-01 21:50:18 -07:00
'django_bcrypt',
2012-04-16 21:42:01 -07:00
'haystack',
2012-04-23 11:34:21 -07:00
'markdown_deux',
2011-10-12 08:29:21 -07:00
'pagination',
2011-12-04 17:01:29 -08:00
'postmark',
2012-02-12 17:17:17 -08:00
'registration',
2011-10-23 17:54:44 -07:00
'south',
2011-06-05 09:51:56 -07:00
'taggit',
2011-10-01 10:23:05 -07:00
'tastypie',
2012-02-12 17:17:17 -08:00
2012-05-24 20:55:30 -07:00
'blogs',
'snipts',
2012-02-15 15:25:13 -08:00
'utils',
2011-06-01 21:50:18 -07:00
)
2011-10-23 17:54:44 -07:00
# 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.
# 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,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
2011-06-01 21:50:18 -07:00
2011-10-23 18:12:45 -07:00
# Email
2012-02-12 17:26:51 -08:00
DEFAULT_FROM_EMAIL = 'site@snipt.net'
2011-12-04 17:45:34 -08:00
SERVER_EMAIL = 'site@snipt.net'
2011-12-04 17:31:33 -08:00
EMAIL_BACKEND = 'postmark.django_backend.EmailBackend'
2011-10-23 18:12:45 -07:00
POSTMARK_API_KEY = '608d3101-1706-4a96-819f-f2f36fe00fe0'
2011-10-23 17:54:44 -07:00
# Grappelli settings
GRAPPELLI_ADMIN_TITLE = '<a href="/">Snipt</a>'
# Virtualenv
2012-03-17 09:05:40 -07:00
if DEBUG:
VIRTUALENV_PATH = '/Users/Nick/.virtualenvs/snipt/lib/python2.7/site-packages/'
else:
VIRTUALENV_PATH = '/home/nick/.virtualenvs/snipt/lib/python2.7/site-packages/'
2011-10-23 17:54:44 -07:00
# Account settings
LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/login/'
LOGOUT_URL = '/logout/'
2012-02-12 21:42:25 -08:00
ACCOUNT_ACTIVATION_DAYS = 0
2011-10-23 17:54:44 -07:00
2012-04-23 19:02:43 -07:00
# HTTPS
if not DEBUG:
USE_HTTPS = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
2012-05-24 20:55:30 -07:00
SESSION_COOKIE_DOMAIN = '.snipt.net'
2012-04-23 19:02:43 -07:00
2012-05-15 17:10:50 -07:00
# Messages
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
2011-10-02 15:38:20 -07:00
# User absolute URLs
ABSOLUTE_URL_OVERRIDES = {
'auth.user': lambda u: "/%s/" % u.username,
}
2011-10-24 20:34:07 -07:00
# Caching
2012-03-06 08:33:01 -08:00
if not DEBUG:
INSTALLED_APPS += ('johnny',)
JOHNNY_MIDDLEWARE_KEY_PREFIX='johnny_snipt'
MIDDLEWARE_CLASSES += (
'johnny.middleware.LocalStoreClearMiddleware',
'johnny.middleware.QueryCacheMiddleware',
)
CACHES = {
'default': dict(
BACKEND = 'johnny.backends.memcached.MemcachedCache',
LOCATION = ['127.0.0.1:11211'],
JOHNNY_CACHE = True,
)
}
2011-12-04 09:00:51 -08:00
2012-03-05 13:38:37 -08:00
# CSS / JS Compression
COMPRESS_OUTPUT_DIR = 'cache'
COMPRESS_JS_FILTERS = []
2012-04-08 16:15:11 -07:00
COMPRESS_ENABLED = True
2012-03-05 13:38:37 -08:00
if DEBUG:
COMPRESS_ROOT = os.path.join(BASE_PATH, 'media')
else:
COMPRESS_ROOT = STATIC_ROOT
2012-04-08 16:15:11 -07:00
COMPRESS_PRECOMPILERS = (
2012-05-07 12:57:06 -07:00
('text/x-scss', 'scss {infile} {outfile}'),
2012-04-08 16:15:11 -07:00
)
2011-12-26 18:52:17 -08:00
2012-04-16 21:42:01 -07:00
# Search
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr'
},
}
2011-12-04 09:00:51 -08:00
# Extensions
if DEBUG:
INSTALLED_APPS += ('django_extensions',)