mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 09:36:52 +03:00
Merge pull request #215 from pydanny/use-django-environ
Replace django-configuration with django-environ: Awesome effort by @theskumar
This commit is contained in:
commit
2781fdc755
|
@ -24,7 +24,7 @@ Features
|
|||
* For Django 1.7
|
||||
* Twitter Bootstrap_ 3
|
||||
* AngularJS_
|
||||
* Settings management via django-configurations_
|
||||
* Settings management via django-environ_
|
||||
* Registration via django-allauth_
|
||||
* User avatars via django-avatar_
|
||||
* Procfile_ for deploying to Heroku
|
||||
|
@ -35,7 +35,7 @@ Features
|
|||
|
||||
.. _Bootstrap: https://github.com/twbs/bootstrap
|
||||
.. _AngularJS: https://github.com/angular/angular.js
|
||||
.. _django-configurations: https://github.com/jezdez/django-configurations
|
||||
.. _django-environ: https://github.com/joke2k/django-environ
|
||||
.. _django-allauth: https://github.com/pennersr/django-allauth
|
||||
.. _django-avatar: https://github.com/jezdez/django-avatar/
|
||||
.. _Procfile: https://devcenter.heroku.com/articles/procfile
|
||||
|
@ -84,7 +84,7 @@ It prompts you for questions. Answer them::
|
|||
description (default is "A short description of the project.")? A reddit clone.
|
||||
domain_name (default is "example.com")? myreddit.com
|
||||
version (default is "0.1.0")? 0.0.1
|
||||
timezone (default is "UTC")?
|
||||
timezone (default is "UTC")?
|
||||
now (default is "2015/01/13")? 2015/01/16
|
||||
year (default is "2015")?
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ Environment Variable Django Setting Development
|
|||
DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a raises error
|
||||
DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error
|
||||
DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error
|
||||
DJANGO_CACHES CACHES locmem memcached
|
||||
DJANGO_DATABASES DATABASES See code See code
|
||||
DJANGO_CACHES CACHES (default) locmem memcached
|
||||
DJANGO_DATABASES DATABASES (default) See code See code
|
||||
DJANGO_DEBUG DEBUG True False
|
||||
DJANGO_EMAIL_BACKEND EMAIL_BACKEND django.core.mail.backends.console.EmailBackend django.core.mail.backends.smtp.EmailBackend
|
||||
DJANGO_SECRET_KEY SECRET_KEY CHANGEME!!! raises error
|
||||
|
@ -84,7 +84,7 @@ It's time to write the code!!!
|
|||
Deployment
|
||||
------------
|
||||
|
||||
It is possible to deploy to Heroku or to your own server by using Dokku, an open source Heroku clone.
|
||||
It is possible to deploy to Heroku or to your own server by using Dokku, an open source Heroku clone.
|
||||
|
||||
Heroku
|
||||
^^^^^^
|
||||
|
@ -99,7 +99,6 @@ Run these commands to deploy the project to Heroku:
|
|||
heroku addons:add sendgrid:starter
|
||||
heroku addons:add memcachier:dev
|
||||
heroku pg:promote DATABASE_URL
|
||||
heroku config:set DJANGO_CONFIGURATION=Production
|
||||
heroku config:set DJANGO_SECRET_KEY=RANDOM_SECRET_KEY_HERE
|
||||
heroku config:set DJANGO_AWS_ACCESS_KEY_ID=YOUR_AWS_ID_HERE
|
||||
heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE
|
||||
|
@ -113,7 +112,7 @@ Dokku
|
|||
^^^^^
|
||||
|
||||
You need to make sure you have a server running Dokku with at least 1GB of RAM. Backing services are
|
||||
added just like in Heroku however you must ensure you have the relevant Dokku plugins installed.
|
||||
added just like in Heroku however you must ensure you have the relevant Dokku plugins installed.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
|
@ -139,7 +138,6 @@ You can then deploy by running the following commands.
|
|||
ssh -t dokku@yourservername.com dokku memcached:link {{cookiecutter.repo_name}}-memcached {{cookiecutter.repo_name}}
|
||||
ssh -t dokku@yourservername.com dokku postgres:create {{cookiecutter.repo_name}}-postgres
|
||||
ssh -t dokku@yourservername.com dokku postgres:link {{cookiecutter.repo_name}}-postgres {{cookiecutter.repo_name}}
|
||||
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_CONFIGURATION=Production
|
||||
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_SECRET_KEY=RANDOM_SECRET_KEY_HERE
|
||||
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_ACCESS_KEY_ID=YOUR_AWS_ID_HERE
|
||||
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
django>=1.7.7,<1.8
|
||||
|
||||
# Configuration
|
||||
django-configurations==0.8
|
||||
django-environ==0.3.0
|
||||
django-secure==1.0.1
|
||||
django-cache-url==0.8.0
|
||||
dj-database-url==0.3.0
|
||||
|
||||
# Forms
|
||||
django-braces==1.4.0
|
||||
|
|
|
@ -1,5 +1 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .local import Local # noqa
|
||||
from .production import Production # noqa
|
||||
|
|
|
@ -8,267 +8,254 @@ https://docs.djangoproject.com/en/dev/topics/settings/
|
|||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/dev/ref/settings/
|
||||
"""
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
import os
|
||||
from os.path import join, dirname
|
||||
import environ
|
||||
|
||||
from configurations import Configuration, values
|
||||
APPS_DIR = environ.Path(__file__) - 1 # one folder back (/a/b/ - 2 = /a/)
|
||||
ROOT_DIR = APPS_DIR - 1
|
||||
|
||||
BASE_DIR = dirname(dirname(__file__))
|
||||
env = environ.Env()
|
||||
|
||||
# APP CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
DJANGO_APPS = (
|
||||
# Default Django apps:
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
# Useful template tags:
|
||||
# 'django.contrib.humanize',
|
||||
|
||||
# Admin
|
||||
'django.contrib.admin',
|
||||
)
|
||||
THIRD_PARTY_APPS = (
|
||||
'crispy_forms', # Form layouts
|
||||
'avatar', # for user avatars
|
||||
'allauth', # registration
|
||||
'allauth.account', # registration
|
||||
'allauth.socialaccount', # registration
|
||||
)
|
||||
|
||||
# Apps specific for this project go here.
|
||||
LOCAL_APPS = (
|
||||
'users', # custom users app
|
||||
# Your stuff: custom apps go here
|
||||
)
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||
|
||||
# MIDDLEWARE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
MIDDLEWARE_CLASSES = (
|
||||
# Make sure djangosecure.middleware.SecurityMiddleware is listed first
|
||||
'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',
|
||||
)
|
||||
|
||||
# MIGRATIONS CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
MIGRATION_MODULES = {
|
||||
'sites': 'contrib.sites.migrations'
|
||||
}
|
||||
|
||||
# DEBUG
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||
DEBUG = env.bool("DJANGO_DEBUG", False)
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
# SECRET CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||
# Raises ImproperlyConfigured exception if DJANO_SECRET_KEY not in os.environ
|
||||
SECRET_KEY = env("DJANGO_SECRET_KEY")
|
||||
|
||||
# FIXTURE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
|
||||
FIXTURE_DIRS = (
|
||||
str(APPS_DIR.path('fixtures')),
|
||||
)
|
||||
|
||||
# EMAIL CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
|
||||
# END EMAIL 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
|
||||
|
||||
# DATABASE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
||||
DATABASES = {
|
||||
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
|
||||
'default': env.db("DATABASE_URL", default="postgres://localhost/{{cookiecutter.repo_name}}"),
|
||||
}
|
||||
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
||||
|
||||
|
||||
class Common(Configuration):
|
||||
# GENERAL CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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.
|
||||
# In a Windows environment this must be set to your system time zone.
|
||||
TIME_ZONE = '{{ cookiecutter.timezone }}'
|
||||
|
||||
# APP CONFIGURATION
|
||||
DJANGO_APPS = (
|
||||
# Default Django apps:
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
# Useful template tags:
|
||||
# 'django.contrib.humanize',
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
|
||||
SITE_ID = 1
|
||||
|
||||
# Admin
|
||||
'django.contrib.admin',
|
||||
)
|
||||
THIRD_PARTY_APPS = (
|
||||
'crispy_forms', # Form layouts
|
||||
'avatar', # for user avatars
|
||||
'allauth', # registration
|
||||
'allauth.account', # registration
|
||||
'allauth.socialaccount', # registration
|
||||
)
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
|
||||
USE_I18N = True
|
||||
|
||||
# Apps specific for this project go here.
|
||||
LOCAL_APPS = (
|
||||
'users', # custom users app
|
||||
# Your stuff: custom apps go here
|
||||
)
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
|
||||
USE_L10N = True
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||
# END APP CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
|
||||
USE_TZ = True
|
||||
# END GENERAL CONFIGURATION
|
||||
|
||||
# MIDDLEWARE CONFIGURATION
|
||||
MIDDLEWARE_CLASSES = (
|
||||
# Make sure djangosecure.middleware.SecurityMiddleware is listed first
|
||||
'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
|
||||
# TEMPLATE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'allauth.account.context_processors.account',
|
||||
'allauth.socialaccount.context_processors.socialaccount',
|
||||
'django.core.context_processors.debug',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.static',
|
||||
'django.core.context_processors.tz',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.core.context_processors.request',
|
||||
# Your stuff: custom template context processors go here
|
||||
)
|
||||
|
||||
# MIGRATIONS CONFIGURATION
|
||||
MIGRATION_MODULES = {
|
||||
'sites': 'contrib.sites.migrations'
|
||||
}
|
||||
# END MIGRATIONS CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
|
||||
TEMPLATE_DIRS = (
|
||||
str(APPS_DIR.path('templates')),
|
||||
)
|
||||
|
||||
# DEBUG
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||
DEBUG = values.BooleanValue(False)
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
)
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
# END DEBUG
|
||||
# See: http://django-crispy-forms.readthedocs.org/en/latest/install.html#template-packs
|
||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
||||
|
||||
# SECRET CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||
# Note: This key only used for development and testing.
|
||||
# In production, this is changed to a values.SecretValue() setting
|
||||
SECRET_KEY = 'CHANGEME!!!'
|
||||
# END SECRET CONFIGURATION
|
||||
# STATIC FILE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
|
||||
STATIC_ROOT = str(ROOT_DIR('staticfiles'))
|
||||
|
||||
# FIXTURE CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
|
||||
FIXTURE_DIRS = (
|
||||
join(BASE_DIR, 'fixtures'),
|
||||
)
|
||||
# END FIXTURE CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# EMAIL CONFIGURATION
|
||||
EMAIL_BACKEND = values.Value('django.core.mail.backends.smtp.EmailBackend')
|
||||
# END EMAIL CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
|
||||
STATICFILES_DIRS = (
|
||||
str(APPS_DIR.path('static')),
|
||||
)
|
||||
|
||||
# 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/contrib/staticfiles/#staticfiles-finders
|
||||
STATICFILES_FINDERS = (
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
)
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
||||
MANAGERS = ADMINS
|
||||
# END MANAGER CONFIGURATION
|
||||
# MEDIA CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
|
||||
MEDIA_ROOT = str(APPS_DIR('media'))
|
||||
|
||||
# DATABASE CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
||||
DATABASES = values.DatabaseURLValue('postgres://localhost/{{cookiecutter.repo_name}}')
|
||||
# END DATABASE CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# CACHING
|
||||
# Do this here because thanks to django-pylibmc-sasl and pylibmc
|
||||
# memcacheify (used on heroku) is painful to install on windows.
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
'LOCATION': ''
|
||||
# URL Configuration
|
||||
# ------------------------------------------------------------------------------
|
||||
ROOT_URLCONF = 'urls'
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
|
||||
WSGI_APPLICATION = 'wsgi.application'
|
||||
|
||||
# AUTHENTICATION CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
'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'
|
||||
LOGIN_URL = 'account_login'
|
||||
|
||||
# SLUGLIFIER
|
||||
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
|
||||
|
||||
|
||||
# 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,
|
||||
'disable_existing_loggers': False,
|
||||
'filters': {
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse'
|
||||
}
|
||||
}
|
||||
# END CACHING
|
||||
|
||||
# GENERAL CONFIGURATION
|
||||
|
||||
# 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.
|
||||
# In a Windows environment this must be set to your system time zone.
|
||||
TIME_ZONE = '{{ cookiecutter.timezone }}'
|
||||
|
||||
# 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
|
||||
|
||||
# TEMPLATE CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'allauth.account.context_processors.account',
|
||||
'allauth.socialaccount.context_processors.socialaccount',
|
||||
'django.core.context_processors.debug',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.static',
|
||||
'django.core.context_processors.tz',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.core.context_processors.request',
|
||||
# Your stuff: custom template context processors go here
|
||||
)
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
|
||||
TEMPLATE_DIRS = (
|
||||
join(BASE_DIR, 'templates'),
|
||||
)
|
||||
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
)
|
||||
|
||||
# See: http://django-crispy-forms.readthedocs.org/en/latest/install.html#template-packs
|
||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
||||
# END TEMPLATE CONFIGURATION
|
||||
|
||||
# STATIC FILE CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
|
||||
STATIC_ROOT = join(os.path.dirname(BASE_DIR), '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
|
||||
|
||||
# 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
|
||||
|
||||
# URL Configuration
|
||||
ROOT_URLCONF = 'urls'
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
|
||||
WSGI_APPLICATION = 'wsgi.application'
|
||||
# End URL Configuration
|
||||
|
||||
# AUTHENTICATION CONFIGURATION
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
'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'
|
||||
LOGIN_URL = 'account_login'
|
||||
# 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,
|
||||
'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,
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'mail_admins': {
|
||||
'level': 'ERROR',
|
||||
'filters': ['require_debug_false'],
|
||||
'class': 'django.utils.log.AdminEmailHandler'
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'django.request': {
|
||||
'handlers': ['mail_admins'],
|
||||
'level': 'ERROR',
|
||||
'propagate': True,
|
||||
},
|
||||
}
|
||||
# END LOGGING CONFIGURATION
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def post_setup(cls):
|
||||
cls.DATABASES['default']['ATOMIC_REQUESTS'] = True
|
||||
|
||||
# Your common stuff: Below this line define 3rd party library settings
|
||||
# Your common stuff: Below this line define 3rd party library settings
|
||||
|
|
|
@ -1,44 +1,54 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Local Configurations
|
||||
Local settings
|
||||
|
||||
- Runs in Debug mode
|
||||
- Uses console backend for emails
|
||||
- Use Django Debug Toolbar
|
||||
'''
|
||||
from configurations import values
|
||||
from .common import Common
|
||||
|
||||
from .common import *
|
||||
|
||||
# DEBUG
|
||||
# ------------------------------------------------------------------------------
|
||||
DEBUG = env.bool('DJANGO_DEBUG', default=True)
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
# SECRET CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||
# Note: This key only used for development and testing.
|
||||
SECRET_KEY = env("DJANGO_SECRET_KEY", 'CHANGEME!!!')
|
||||
|
||||
# Mail settings
|
||||
# ------------------------------------------------------------------------------
|
||||
EMAIL_HOST = 'localhost'
|
||||
EMAIL_PORT = 1025
|
||||
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND',
|
||||
default='django.core.mail.backends.console.EmailBackend')
|
||||
|
||||
|
||||
class Local(Common):
|
||||
|
||||
# DEBUG
|
||||
DEBUG = values.BooleanValue(True)
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
# END DEBUG
|
||||
|
||||
# INSTALLED_APPS
|
||||
INSTALLED_APPS = Common.INSTALLED_APPS
|
||||
# END INSTALLED_APPS
|
||||
|
||||
# Mail settings
|
||||
EMAIL_HOST = 'localhost'
|
||||
EMAIL_PORT = 1025
|
||||
EMAIL_BACKEND = values.Value('django.core.mail.backends.console.EmailBackend')
|
||||
# End mail settings
|
||||
|
||||
# django-debug-toolbar
|
||||
MIDDLEWARE_CLASSES = Common.MIDDLEWARE_CLASSES + ('debug_toolbar.middleware.DebugToolbarMiddleware',)
|
||||
INSTALLED_APPS += ('debug_toolbar', 'django_extensions',)
|
||||
|
||||
INTERNAL_IPS = ('127.0.0.1', '10.0.2.2',)
|
||||
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
'DISABLE_PANELS': [
|
||||
'debug_toolbar.panels.redirects.RedirectsPanel',
|
||||
],
|
||||
'SHOW_TEMPLATE_CONTEXT': True,
|
||||
# CACHING
|
||||
# ------------------------------------------------------------------------------
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
'LOCATION': ''
|
||||
}
|
||||
# end django-debug-toolbar
|
||||
}
|
||||
|
||||
# Your local stuff: Below this line define 3rd party library settings
|
||||
# django-debug-toolbar
|
||||
# ------------------------------------------------------------------------------
|
||||
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
|
||||
INSTALLED_APPS += ('debug_toolbar', 'django_extensions',)
|
||||
|
||||
INTERNAL_IPS = ('127.0.0.1', '10.0.2.2',)
|
||||
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
'DISABLE_PANELS': [
|
||||
'debug_toolbar.panels.redirects.RedirectsPanel',
|
||||
],
|
||||
'SHOW_TEMPLATE_CONTEXT': True,
|
||||
}
|
||||
|
||||
# Your local stuff: Below this line define 3rd party library settings
|
||||
|
|
|
@ -7,124 +7,114 @@ Production Configurations
|
|||
- Use sendgrid to send emails
|
||||
- Use MEMCACHIER on Heroku
|
||||
'''
|
||||
from configurations import values
|
||||
|
||||
from .common import Common
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
|
||||
class Production(Common):
|
||||
from boto.s3.connection import OrdinaryCallingFormat
|
||||
|
||||
# This ensures that Django will be able to detect a secure connection
|
||||
# properly on Heroku.
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
from .common import *
|
||||
|
||||
# INSTALLED_APPS
|
||||
INSTALLED_APPS = Common.INSTALLED_APPS
|
||||
# END INSTALLED_APPS
|
||||
# This ensures that Django will be able to detect a secure connection
|
||||
# properly on Heroku.
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
|
||||
# SECRET KEY
|
||||
SECRET_KEY = values.SecretValue()
|
||||
# END SECRET KEY
|
||||
# django-secure
|
||||
# ------------------------------------------------------------------------------
|
||||
INSTALLED_APPS += ("djangosecure", )
|
||||
|
||||
# django-secure
|
||||
INSTALLED_APPS += ("djangosecure", )
|
||||
MIDDLEWARE_CLASSES = (
|
||||
# Make sure djangosecure.middleware.SecurityMiddleware is listed first
|
||||
'djangosecure.middleware.SecurityMiddleware',
|
||||
) + MIDDLEWARE_CLASSES
|
||||
|
||||
# MIDDLEWARE CONFIGURATION
|
||||
MIDDLEWARE_CLASSES = (
|
||||
# Make sure djangosecure.middleware.SecurityMiddleware is listed first
|
||||
'djangosecure.middleware.SecurityMiddleware',
|
||||
)
|
||||
# set this to 60 seconds and then to 518400 when you can prove it works
|
||||
SECURE_HSTS_SECONDS = 60
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool("DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True)
|
||||
SECURE_FRAME_DENY = env.bool("DJANGO_SECURE_FRAME_DENY", default=True)
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = env.bool("DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True)
|
||||
SECURE_BROWSER_XSS_FILTER = True
|
||||
SESSION_COOKIE_SECURE = False
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
SECURE_SSL_REDIRECT = env.bool("DJANGO_SECURE_SSL_REDIRECT", default=True)
|
||||
|
||||
MIDDLEWARE_CLASSES += Common.MIDDLEWARE_CLASSES
|
||||
# END MIDDLEWARE CONFIGURATION
|
||||
# SITE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# Hosts/domain names that are valid for this site
|
||||
# See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
# END SITE CONFIGURATION
|
||||
|
||||
# set this to 60 seconds and then to 518400 when you can prove it works
|
||||
SECURE_HSTS_SECONDS = 60
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = values.BooleanValue(True)
|
||||
SECURE_FRAME_DENY = values.BooleanValue(True)
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True)
|
||||
SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True)
|
||||
SESSION_COOKIE_SECURE = values.BooleanValue(False)
|
||||
SESSION_COOKIE_HTTPONLY = values.BooleanValue(True)
|
||||
SECURE_SSL_REDIRECT = values.BooleanValue(True)
|
||||
# end django-secure
|
||||
INSTALLED_APPS += ("gunicorn", )
|
||||
|
||||
# SITE CONFIGURATION
|
||||
# Hosts/domain names that are valid for this site
|
||||
# See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
# END SITE CONFIGURATION
|
||||
# STORAGE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: http://django-storages.readthedocs.org/en/latest/index.html
|
||||
INSTALLED_APPS += (
|
||||
'storages',
|
||||
)
|
||||
|
||||
INSTALLED_APPS += ("gunicorn", )
|
||||
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
|
||||
|
||||
# STORAGE CONFIGURATION
|
||||
# See: http://django-storages.readthedocs.org/en/latest/index.html
|
||||
INSTALLED_APPS += (
|
||||
'storages',
|
||||
)
|
||||
AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID")
|
||||
AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY")
|
||||
AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
|
||||
AWS_AUTO_CREATE_BUCKET = True
|
||||
AWS_QUERYSTRING_AUTH = False
|
||||
AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat()
|
||||
|
||||
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
|
||||
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
|
||||
# See: https://github.com/antonagestam/collectfast
|
||||
# For Django 1.7+, 'collectfast' should come before 'django.contrib.staticfiles'
|
||||
AWS_PRELOAD_METADATA = True
|
||||
INSTALLED_APPS = ('collectfast', ) + INSTALLED_APPS
|
||||
|
||||
# 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_EXPIRY = 60 * 60 * 24 * 7
|
||||
AWS_HEADERS = {
|
||||
'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (
|
||||
AWS_EXPIRY, AWS_EXPIRY)
|
||||
}
|
||||
|
||||
# See: https://github.com/antonagestam/collectfast
|
||||
# For Django 1.7+, 'collectfast' should come before 'django.contrib.staticfiles'
|
||||
AWS_PRELOAD_METADATA = True
|
||||
INSTALLED_APPS = ('collectfast', ) + INSTALLED_APPS
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
|
||||
STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
|
||||
|
||||
# AWS cache settings, don't change unless you know what you're doing:
|
||||
AWS_EXPIRY = 60 * 60 * 24 * 7
|
||||
AWS_HEADERS = {
|
||||
'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (
|
||||
AWS_EXPIRY, AWS_EXPIRY)
|
||||
}
|
||||
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html
|
||||
try:
|
||||
from boto.s3.connection import OrdinaryCallingFormat
|
||||
AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat()
|
||||
except ImportError:
|
||||
pass
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL',
|
||||
default='{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>')
|
||||
EMAIL_HOST = env("DJANGO_EMAIL_HOST", default='smtp.sendgrid.com')
|
||||
EMAIL_HOST_PASSWORD = env("SENDGRID_PASSWORD")
|
||||
EMAIL_HOST_USER = env('SENDGRID_USERNAME')
|
||||
EMAIL_PORT = env.int("EMAIL_PORT", default=587)
|
||||
EMAIL_SUBJECT_PREFIX = env("EMAIL_SUBJECT_PREFIX", default='[{{cookiecutter.project_name}}] ')
|
||||
EMAIL_USE_TLS = True
|
||||
SERVER_EMAIL = EMAIL_HOST_USER
|
||||
|
||||
# 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
|
||||
# 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',
|
||||
)),
|
||||
)
|
||||
|
||||
# EMAIL
|
||||
DEFAULT_FROM_EMAIL = values.Value('{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>')
|
||||
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
|
||||
# DATABASE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
|
||||
DATABASES['defalut'] = env.db("DATABASE_URL")
|
||||
|
||||
# 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
|
||||
# CACHING
|
||||
# ------------------------------------------------------------------------------
|
||||
try:
|
||||
# Only do this here because thanks to django-pylibmc-sasl and pylibmc
|
||||
# memcacheify is painful to install on windows.
|
||||
try:
|
||||
# See: https://github.com/rdegges/django-heroku-memcacheify
|
||||
from memcacheify import memcacheify
|
||||
CACHES = memcacheify()
|
||||
except ImportError:
|
||||
CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211")
|
||||
# END CACHING
|
||||
# See: https://github.com/rdegges/django-heroku-memcacheify
|
||||
from memcacheify import memcacheify
|
||||
CACHES = memcacheify()
|
||||
except ImportError:
|
||||
CACHES = {
|
||||
'default': env.cache_url("DJANGO_CACHE_URL", default="memcache://127.0.0.1:11211"),
|
||||
}
|
||||
|
||||
# Your production stuff: Below this line define 3rd party library settings
|
||||
# Your production stuff: Below this line define 3rd party library settings
|
||||
|
|
|
@ -3,9 +3,8 @@ import os
|
|||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config")
|
||||
os.environ.setdefault("DJANGO_CONFIGURATION", "Local")
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.local")
|
||||
|
||||
from configurations.management import execute_from_command_line
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
execute_from_command_line(sys.argv)
|
||||
|
|
|
@ -19,13 +19,12 @@ import os
|
|||
# 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", "config")
|
||||
os.environ.setdefault("DJANGO_CONFIGURATION", "Production")
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.production")
|
||||
|
||||
# This application object is used by any WSGI server configured to use this
|
||||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
# setting points here.
|
||||
from configurations.wsgi import get_wsgi_application # noqa
|
||||
from django.core.wsgi import get_wsgi_application # noqa
|
||||
application = get_wsgi_application()
|
||||
|
||||
# Apply WSGI middleware here.
|
||||
|
|
Loading…
Reference in New Issue
Block a user