Add django-configurations

This commit is contained in:
Daniel Greenfeld 2013-09-15 15:02:13 +02:00
parent a2070558c9
commit cee802c859
6 changed files with 317 additions and 273 deletions

View File

@ -4,6 +4,6 @@
"author_name": "Your Name", "author_name": "Your Name",
"email": "Your email", "email": "Your email",
"description": "A short description of the project.", "description": "A short description of the project.",
"year": "Current year", "year": "2013",
"domain_name": "Domain name" "domain_name": "example.com"
} }

View File

@ -14,9 +14,9 @@ Deployment
* heroku addons:add pgbackups * heroku addons:add pgbackups
* heroku addons:add sendgrid:starter * heroku addons:add sendgrid:starter
* heroku pg:promote HEROKU_POSTGRESQL_COLOR * heroku pg:promote HEROKU_POSTGRESQL_COLOR
* heroku config:add AWS_ACCESS_KEY_ID=YOUR_ID * heroku config:add DJANGO_AWS_ACCESS_KEY_ID=YOUR_ID
* heroku config:add AWS_SECRET_ACCESS_KEY=YOUR_KEY * heroku config:add DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_KEY
* heroku config:add AWS_STORAGE_BUCKET_NAME=BUCKET * heroku config:add DJANGO_AWS_STORAGE_BUCKET_NAME=BUCKET
* git push heroku master * git push heroku master
* heroku run python {{cookiecutter.repo_name}}/manage.py syncdb --noinput --settings=config.settings * heroku run python {{cookiecutter.repo_name}}/manage.py syncdb --noinput --settings=config.settings
* heroku run python {{cookiecutter.repo_name}}/manage.py migrate --settings=config.settings * heroku run python {{cookiecutter.repo_name}}/manage.py migrate --settings=config.settings

View File

@ -1,17 +1,25 @@
# Bleeding edge Django # Bleeding edge Django
https://github.com/django/django/archive/1.6b1.tar.gz https://github.com/django/django/archive/1.6b1.tar.gz
# Views, models, forms, and images fundamentals # Configuration
django-braces==1.2.2
django-model-utils==1.4.0
django-floppyforms==1.1
Pillow==2.1.0
dj-database-url==0.2.2 dj-database-url==0.2.2
django-configurations==0.5.1
django-secure==1.0 django-secure==1.0
# Forms
django-braces==1.2.2
django-crispy-forms==1.4.0
django-floppyforms==1.1
# Models
django-model-utils==1.5.0
# images
Pillow==2.1.0
# For user registration, either via email or social # For user registration, either via email or social
# Well-built with regular release cycles! # Well-built with regular release cycles!
django-allauth==0.12.0 django-allauth==0.13.0
# For the persistance stores # For the persistance stores
psycopg2==2.5 psycopg2==2.5
@ -30,8 +38,4 @@ https://bitbucket.org/andrewgodwin/south/get/59f6bae8b1a501ca14a5f23f8b11c44c42f
git+git://github.com/jezdez/django-avatar@6393d25166a6c2d2df0bd28e19f161fac2bb1166 git+git://github.com/jezdez/django-avatar@6393d25166a6c2d2df0bd28e19f161fac2bb1166
# django-crispy-forms with support for Bootstrap 3
django-crispy-forms==1.4.0
# Your custom requirements go here # Your custom requirements go here

View File

@ -12,121 +12,11 @@ https://docs.djangoproject.com/en/dev/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os import os
from os.path import join from os.path import join
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
########## DEBUG CONFIGURATION
if os.environ.get("DATABASE_URL", None):
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = False
else:
DEBUG = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION
########## SECRET CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
# Note: This key only used for development and testing.
SECRET_KEY = "CHANGEME!!!"
########## END SECRET CONFIGURATION
########## FIXTURE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
FIXTURE_DIRS = (
join(BASE_DIR, 'fixtures'),
)
########## END FIXTURE CONFIGURATION
########## MANAGER CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
ADMINS = (
('{{cookiecutter.author_name}}', '{{cookiecutter.email}}'),
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
MANAGERS = ADMINS
########## END MANAGER CONFIGURATION
########## DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
import dj_database_url import dj_database_url
DATABASES = {'default': dj_database_url.config()} from configurations import Configuration, values
if DATABASES == {'default': {}}:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': "{{cookiecutter.repo_name}}",
}
}
########## END DATABASE CONFIGURATION
########## GENERAL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
TIME_ZONE = 'America/Los_Angeles'
# See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
LANGUAGE_CODE = 'en-us'
# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
SITE_ID = 1
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
USE_I18N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
USE_L10N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True
########## END GENERAL CONFIGURATION
########## MEDIA CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = join(BASE_DIR, 'media')
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = '/media/'
########## END MEDIA CONFIGURATION
########## MIDDLEWARE CONFIGURATION
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
########## END MIDDLEWARE CONFIGURATION
########## STATIC FILE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = 'staticfiles'
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = '/static/'
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = (
join(BASE_DIR, 'static'),
)
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
########## END STATIC FILE CONFIGURATION
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
########## APP CONFIGURATION ########## APP CONFIGURATION
DJANGO_APPS = ( DJANGO_APPS = (
@ -168,135 +58,107 @@ INSTALLED_APPS += (
) )
########## END APP CONFIGURATION ########## END APP CONFIGURATION
########## MIDDLEWARE CONFIGURATION
########## URL Configuration MIDDLEWARE_CLASSES = (
ROOT_URLCONF = 'config.urls' 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application 'django.middleware.csrf.CsrfViewMiddleware',
WSGI_APPLICATION = 'config.wsgi.application' 'django.contrib.auth.middleware.AuthenticationMiddleware',
########## End URL Configuration 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
########## django-secure
SECURE = False
if SECURE:
INSTALLED_APPS += ("djangosecure", )
# set this to 60 seconds and then to 518400 when you can prove it works
SECURE_HSTS_SECONDS = 60
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_FRAME_DENY = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
SECURE_SSL_REDIRECT = True
########## end django-secure
########## AUTHENTICATION CONFIGURATION
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
) )
########## END MIDDLEWARE CONFIGURATION
# Some really nice defaults
ACCOUNT_AUTHENTICATION_METHOD = "username"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
########## END AUTHENTICATION CONFIGURATION
########## Custom user app defaults class Common(Configuration):
# Select the correct user model
AUTH_USER_MODEL = "users.User"
LOGIN_REDIRECT_URL = "users:redirect"
########## END Custom user app defaults
########## INSTALLED_APPS
INSTALLED_APPS = INSTALLED_APPS
########## END INSTALLED_APPS
########## SLUGLIFIER ########## MIDDLEWARE CONFIGURATION
AUTOSLUG_SLUGIFY_FUNCTION = "slugify.slugify" MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES
########## END SLUGLIFIER ########## END MIDDLEWARE CONFIGURATION
########## DEBUG
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = values.BooleanValue(True)
################## PRODUCTION SETTINGS # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
if DEBUG:
EMAIL_HOST = "localhost"
EMAIL_PORT = 1025
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
INSTALLED_APPS += ('debug_toolbar',)
INTERNAL_IPS = ('127.0.0.1',)
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TEMPLATE_CONTEXT': True,
}
else:
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
########## END DEBUG
########## SITE CONFIGURATION ########## SECRET CONFIGURATION
# Hosts/domain names that are valid for this site # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts # Note: This key only used for development and testing.
ALLOWED_HOSTS = ["*"] # In production, this is changed to a values.SecretValue() setting
########## END SITE CONFIGURATION SECRET_KEY = "CHANGEME!!!"
########## END SECRET CONFIGURATION
INSTALLED_APPS += ("gunicorn", ) ########## FIXTURE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
FIXTURE_DIRS = (
join(BASE_DIR, 'fixtures'),
)
########## END FIXTURE CONFIGURATION
########## STORAGE CONFIGURATION ########## MANAGER CONFIGURATION
from S3 import CallingFormat # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
from os import environ ADMINS = (
# See: http://django-storages.readthedocs.org/en/latest/index.html ('{{cookiecutter.author_name}}', '{{cookiecutter.email}}'),
INSTALLED_APPS += (
'storages',
) )
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' MANAGERS = ADMINS
########## END MANAGER CONFIGURATION
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings ########## DATABASE CONFIGURATION
AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings DATABASES = {'default': dj_database_url.config()}
AWS_ACCESS_KEY_ID = environ.get('AWS_ACCESS_KEY_ID', '') if DATABASES == {'default': {}}:
AWS_SECRET_ACCESS_KEY = environ.get('AWS_SECRET_ACCESS_KEY', '') DATABASES = {
AWS_STORAGE_BUCKET_NAME = environ.get('AWS_STORAGE_BUCKET_NAME', '') 'default': {
AWS_AUTO_CREATE_BUCKET = True 'ENGINE': 'django.db.backends.postgresql_psycopg2',
AWS_QUERYSTRING_AUTH = False 'NAME': "{{cookiecutter.repo_name}}",
# AWS cache settings, don't change unless you know what you're doing:
AWS_EXPIREY = 60 * 60 * 24 * 7
AWS_HEADERS = {
'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
AWS_EXPIREY)
} }
}
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url ########## END DATABASE CONFIGURATION
STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
########## END STORAGE CONFIGURATION
########## EMAIL
DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL',
'{{cookiecutter.project_name}} <{{cookiecutter.project_name}}-noreply@{{cookiecutter.domain_name}}>')
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.environ.get('EMAIL_HOST', 'smtp.sendgrid.com')
EMAIL_HOST_PASSWORD = os.environ.get('SENDGRID_PASSWORD', '')
EMAIL_HOST_USER = os.environ.get('SENDGRID_USERNAME', '')
EMAIL_PORT = os.environ.get('EMAIL_PORT', 587)
EMAIL_SUBJECT_PREFIX = os.environ.get('EMAIL_SUBJECT_PREFIX', '[{{cookiecutter.project_name}}] ')
EMAIL_USE_TLS = True
SERVER_EMAIL = EMAIL_HOST_USER
########## END EMAIL
########## CACHING ########## CACHING
from memcacheify import memcacheify # Do this here because thanks to django-pylibmc-sasl and pylibmc memcacheify is painful to install on windows.
CACHES = memcacheify() # memcacheify is what's used in Production
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake'
}
}
########## END CACHING ########## END CACHING
########## GENERAL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
TIME_ZONE = 'America/Los_Angeles'
########## TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors LANGUAGE_CODE = 'en-us'
TEMPLATE_CONTEXT_PROCESSORS = (
# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
SITE_ID = 1
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
USE_I18N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
USE_L10N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True
########## END GENERAL CONFIGURATION
########## TEMPLATE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
"allauth.account.context_processors.account", "allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount", "allauth.socialaccount.context_processors.socialaccount",
@ -308,40 +170,86 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request', 'django.core.context_processors.request',
# Your stuff: custom template context processers go here # Your stuff: custom template context processers go here
) )
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_DIRS = (
TEMPLATE_DIRS = (
join(BASE_DIR, 'templates'), join(BASE_DIR, 'templates'),
) )
if DEBUG:
TEMPLATE_LOADERS = ( TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader', 'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader', 'django.template.loaders.app_directories.Loader',
) )
else:
TEMPLATE_LOADERS = ( # See: http://django-crispy-forms.readthedocs.org/en/latest/install.html#template-packs
('django.template.loaders.cached.Loader', ( CRISPY_TEMPLATE_PACK = 'bootstrap3'
'django.template.loaders.filesystem.Loader', ########## END TEMPLATE CONFIGURATION
'django.template.loaders.app_directories.Loader',
)), ########## MEDIA CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = join(BASE_DIR, 'media')
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = '/media/'
########## END MEDIA CONFIGURATION
########## STATIC FILE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = 'staticfiles'
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = '/static/'
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = (
join(BASE_DIR, 'static'),
) )
# See: http://django-crispy-forms.readthedocs.org/en/latest/install.html#template-packs # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
CRISPY_TEMPLATE_PACK = 'bootstrap3' STATICFILES_FINDERS = (
########## END TEMPLATE CONFIGURATION 'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
########## END STATIC FILE CONFIGURATION
########## URL Configuration
ROOT_URLCONF = 'config.urls'
########## LOGGING CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging WSGI_APPLICATION = 'config.wsgi.application'
# A sample logging configuration. The only tangible logging ########## End URL Configuration
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False. ########## AUTHENTICATION CONFIGURATION
# See http://docs.djangoproject.com/en/dev/topics/logging for AUTHENTICATION_BACKENDS = (
# more details on how to customize your logging configuration. "django.contrib.auth.backends.ModelBackend",
LOGGING = { "allauth.account.auth_backends.AuthenticationBackend",
)
# Some really nice defaults
ACCOUNT_AUTHENTICATION_METHOD = "username"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
########## END AUTHENTICATION CONFIGURATION
########## Custom user app defaults
# Select the correct user model
AUTH_USER_MODEL = "users.User"
LOGIN_REDIRECT_URL = "users:redirect"
########## END Custom user app defaults
########## SLUGLIFIER
AUTOSLUG_SLUGIFY_FUNCTION = "slugify.slugify"
########## END SLUGLIFIER
########## LOGGING CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
# 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, 'version': 1,
'disable_existing_loggers': False, 'disable_existing_loggers': False,
'filters': { 'filters': {
@ -363,9 +271,135 @@ LOGGING = {
'propagate': True, 'propagate': True,
}, },
} }
} }
########## END LOGGING CONFIGURATION ########## END LOGGING CONFIGURATION
########## Your stuff: Below this line define 3rd party libary settings ########## Your common stuff: Below this line define 3rd party libary settings
class Local(Common):
########## INSTALLED_APPS
INSTALLED_APPS = INSTALLED_APPS
########## END INSTALLED_APPS
########## Mail settings
EMAIL_HOST = "localhost"
EMAIL_PORT = 1025
########## End mail settings
########## django-debug-toolbar
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
INSTALLED_APPS += ('debug_toolbar',)
INTERNAL_IPS = ('127.0.0.1',)
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TEMPLATE_CONTEXT': True,
}
########## end django-debug-toolbar
########## Your local stuff: Below this line define 3rd party libary settings
class Production(Common):
########## INSTALLED_APPS
INSTALLED_APPS = INSTALLED_APPS
########## END INSTALLED_APPS
########## SECRET KEY
SECRET_KEY = values.SecretValue()
########## END SECRET KEY
########## django-secure
INSTALLED_APPS += ("djangosecure", )
# set this to 60 seconds and then to 518400 when you can prove it works
SECURE_HSTS_SECONDS = 60
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_FRAME_DENY = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
SECURE_SSL_REDIRECT = True
########## end django-secure
########## SITE CONFIGURATION
# Hosts/domain names that are valid for this site
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["*"]
########## END SITE CONFIGURATION
INSTALLED_APPS += ("gunicorn", )
########## STORAGE CONFIGURATION
# See: http://django-storages.readthedocs.org/en/latest/index.html
INSTALLED_APPS += (
'storages',
)
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
try:
from S3 import CallingFormat
AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
except ImportError:
# TODO: Fix this where even if in Dev this class is called.
pass
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
AWS_ACCESS_KEY_ID = values.SecretValue()
AWS_SECRET_ACCESS_KEY = values.SecretValue()
AWS_STORAGE_BUCKET_NAME = values.SecretValue()
AWS_AUTO_CREATE_BUCKET = True
AWS_QUERYSTRING_AUTH = False
# AWS cache settings, don't change unless you know what you're doing:
AWS_EXPIREY = 60 * 60 * 24 * 7
AWS_HEADERS = {
'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
AWS_EXPIREY)
}
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
########## END STORAGE CONFIGURATION
########## EMAIL
DEFAULT_FROM_EMAIL = values.Value(
'{{cookiecutter.project_name}} <{{cookiecutter.project_name}}-noreply@{{cookiecutter.domain_name}}>')
EMAIL_BACKEND = values.Value('django.core.mail.backends.smtp.EmailBackend')
EMAIL_HOST = values.Value('smtp.sendgrid.com')
EMAIL_HOST_PASSWORD = values.SecretValue(environ_prefix="", environ_name="SENDGRID_PASSWORD")
EMAIL_HOST_USER = values.SecretValue(environ_prefix="", environ_name="SENDGRID_USERNAME")
EMAIL_PORT = values.IntegerValue(587, environ_prefix="", environ_name="EMAIL_PORT")
EMAIL_SUBJECT_PREFIX = values.Value('[{{cookiecutter.project_name}}] ', environ_name="EMAIL_SUBJECT_PREFIX")
EMAIL_USE_TLS = True
SERVER_EMAIL = EMAIL_HOST_USER
########## END EMAIL
########## TEMPLATE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
TEMPLATE_LOADERS = (
('django.template.loaders.cached.Loader', (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)),
)
########## END TEMPLATE CONFIGURATION
########## CACHING
# Only do this here because thanks to django-pylibmc-sasl and pylibmc memcacheify is painful to install on windows.
from memcacheify import memcacheify
CACHES = memcacheify()
########## END CACHING
########## Your production stuff: Below this line define 3rd party libary settings

View File

@ -14,15 +14,20 @@ framework.
""" """
import os import os
from os.path import abspath, dirname
from sys import path
SITE_ROOT = dirname(dirname(abspath(__file__))) # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
path.append(SITE_ROOT) # if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "{{ repo_name }}.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ cookiecutter.repo_name }}.config.settings")
os.environ.setdefault("DJANGO_CONFIGURATION", "Local")
# This application object is used by any WSGI server configured to use this
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") # file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from configurations.wsgi import get_wsgi_application
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application() application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)

View File

@ -4,7 +4,8 @@ import sys
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
os.environ.setdefault("DJANGO_CONFIGURATION", "Local")
from django.core.management import execute_from_command_line from configurations.management import execute_from_command_line
execute_from_command_line(sys.argv) execute_from_command_line(sys.argv)