mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-02-03 13:14:28 +03:00
Prettify and re-order settings entries (#1550)
* Prettify and re-order settings entries * Use old-style .format() for the time being * Remove redundant linebreaks at the settings files' beginning * Fix E303 too many blank lines * Remove a redundant linebreak from requirements.txt * Some linebreake juggling in config.settings.base
This commit is contained in:
parent
5380117181
commit
d2791b019a
|
@ -13,6 +13,5 @@ pyflakes==1.6.0
|
||||||
# Testing
|
# Testing
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
tox==2.9.1
|
tox==2.9.1
|
||||||
|
|
||||||
pytest==3.4.2
|
pytest==3.4.2
|
||||||
pytest-cookies==0.3.0
|
pytest-cookies==0.3.0
|
||||||
|
|
|
@ -1,238 +1,119 @@
|
||||||
"""
|
"""
|
||||||
Base settings for {{cookiecutter.project_name}} project.
|
Base settings to build other settings files upon.
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
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/
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import environ
|
import environ
|
||||||
|
|
||||||
ROOT_DIR = environ.Path(__file__) - 3 # ({{ cookiecutter.project_slug }}/config/settings/base.py - 3 = {{ cookiecutter.project_slug }}/)
|
ROOT_DIR = environ.Path(__file__) - 3 # ({{ cookiecutter.project_slug }}/config/settings/base.py - 3 = {{ cookiecutter.project_slug }}/)
|
||||||
APPS_DIR = ROOT_DIR.path('{{ cookiecutter.project_slug }}')
|
APPS_DIR = ROOT_DIR.path('{{ cookiecutter.project_slug }}')
|
||||||
|
|
||||||
# Load operating system environment variables and then prepare to use them
|
|
||||||
env = environ.Env()
|
env = environ.Env()
|
||||||
|
|
||||||
# .env file, should load only in development environment
|
|
||||||
READ_DOT_ENV_FILE = env.bool('DJANGO_READ_DOT_ENV_FILE', default=False)
|
READ_DOT_ENV_FILE = env.bool('DJANGO_READ_DOT_ENV_FILE', default=False)
|
||||||
|
|
||||||
if READ_DOT_ENV_FILE:
|
if READ_DOT_ENV_FILE:
|
||||||
# Operating System Environment variables have precedence over variables defined in the .env file,
|
# OS environment variables take precedence over variables from .env
|
||||||
# that is to say variables from the .env files will only be used if not defined
|
env.read_env(str(ROOT_DIR.path('.env')))
|
||||||
# as environment variables.
|
|
||||||
env_file = str(ROOT_DIR.path('.env'))
|
|
||||||
print('Loading : {}'.format(env_file))
|
|
||||||
env.read_env(env_file)
|
|
||||||
print('The .env file has been loaded. See base.py for more information')
|
|
||||||
|
|
||||||
# APP CONFIGURATION
|
# GENERAL
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||||
|
DEBUG = env.bool('DJANGO_DEBUG', False)
|
||||||
|
# Local time zone. Choices are
|
||||||
|
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||||
|
# though not all of them may be available with every OS.
|
||||||
|
# In Windows, this must be set to your system time zone.
|
||||||
|
TIME_ZONE = '{{ cookiecutter.timezone }}'
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#language-code
|
||||||
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#site-id
|
||||||
|
SITE_ID = 1
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
|
||||||
|
USE_I18N = True
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
|
||||||
|
USE_L10N = True
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
# DATABASES
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
||||||
|
{% if cookiecutter.use_docker == 'y' -%}
|
||||||
|
DATABASES = {
|
||||||
|
'default': env.db('DATABASE_URL'),
|
||||||
|
}
|
||||||
|
{%- else %}
|
||||||
|
DATABASES = {
|
||||||
|
'default': env.db('DATABASE_URL', default='postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}'),
|
||||||
|
}
|
||||||
|
{%- endif %}
|
||||||
|
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
||||||
|
|
||||||
|
# URLS
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
|
||||||
|
ROOT_URLCONF = 'config.urls'
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
|
||||||
|
WSGI_APPLICATION = 'config.wsgi.application'
|
||||||
|
|
||||||
|
# APPS
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
DJANGO_APPS = [
|
DJANGO_APPS = [
|
||||||
# Default Django apps:
|
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.sites',
|
'django.contrib.sites',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
# 'django.contrib.humanize', # Handy template tags
|
||||||
# Useful template tags:
|
|
||||||
# 'django.contrib.humanize',
|
|
||||||
|
|
||||||
# Admin
|
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
]
|
]
|
||||||
THIRD_PARTY_APPS = [
|
THIRD_PARTY_APPS = [
|
||||||
'crispy_forms', # Form layouts
|
'crispy_forms',
|
||||||
'allauth', # registration
|
|
||||||
'allauth.account', # registration
|
|
||||||
'allauth.socialaccount', # registration
|
|
||||||
]
|
|
||||||
|
|
||||||
# Apps specific for this project go here.
|
'allauth',
|
||||||
|
'allauth.account',
|
||||||
|
'allauth.socialaccount',
|
||||||
|
]
|
||||||
LOCAL_APPS = [
|
LOCAL_APPS = [
|
||||||
# custom users app
|
|
||||||
'{{ cookiecutter.project_slug }}.users.apps.UsersConfig',
|
'{{ cookiecutter.project_slug }}.users.apps.UsersConfig',
|
||||||
# Your stuff: custom apps go here
|
# Your stuff: custom apps go here
|
||||||
]
|
]
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
|
||||||
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||||
|
|
||||||
# MIDDLEWARE CONFIGURATION
|
# MIGRATIONS
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'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
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#migration-modules
|
||||||
MIGRATION_MODULES = {
|
MIGRATION_MODULES = {
|
||||||
'sites': '{{ cookiecutter.project_slug }}.contrib.sites.migrations'
|
'sites': '{{ cookiecutter.project_slug }}.contrib.sites.migrations'
|
||||||
}
|
}
|
||||||
|
|
||||||
# DEBUG
|
# AUTHENTICATION
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
# https://docs.djangoproject.com/en/dev/ref/settings/#authentication-backends
|
||||||
DEBUG = env.bool('DJANGO_DEBUG', False)
|
AUTHENTICATION_BACKENDS = [
|
||||||
|
'django.contrib.auth.backends.ModelBackend',
|
||||||
# FIXTURE CONFIGURATION
|
'allauth.account.auth_backends.AuthenticationBackend',
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# 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')
|
|
||||||
|
|
||||||
# MANAGER CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
|
||||||
ADMINS = [
|
|
||||||
("""{{cookiecutter.author_name}}""", '{{cookiecutter.email}}'),
|
|
||||||
]
|
]
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-user-model
|
||||||
|
AUTH_USER_MODEL = 'users.User'
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
|
||||||
|
LOGIN_REDIRECT_URL = 'users:redirect'
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#login-url
|
||||||
|
LOGIN_URL = 'account_login'
|
||||||
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
# PASSWORDS
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
# DATABASE CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
|
||||||
# Uses django-environ to accept uri format
|
|
||||||
# See: https://django-environ.readthedocs.io/en/latest/#supported-types
|
|
||||||
{% if cookiecutter.use_docker == 'y' %}
|
|
||||||
DATABASES = {
|
|
||||||
'default': env.db('DATABASE_URL'),
|
|
||||||
}
|
|
||||||
{% else %}
|
|
||||||
DATABASES = {
|
|
||||||
'default': env.db('DATABASE_URL', default='postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}'),
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
||||||
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# TEMPLATE CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
|
|
||||||
'DIRS': [
|
|
||||||
str(APPS_DIR.path('templates')),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
|
|
||||||
'debug': DEBUG,
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
|
|
||||||
# https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
|
|
||||||
'loaders': [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
],
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
|
|
||||||
'context_processors': [
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.media',
|
|
||||||
'django.template.context_processors.static',
|
|
||||||
'django.template.context_processors.tz',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
# Your stuff: custom template context processors go here
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
# See: http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
|
||||||
|
|
||||||
# STATIC FILE CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
|
|
||||||
STATIC_ROOT = str(ROOT_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 = [
|
|
||||||
str(APPS_DIR.path('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',
|
|
||||||
]
|
|
||||||
|
|
||||||
# MEDIA CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
|
|
||||||
MEDIA_ROOT = str(APPS_DIR('media'))
|
|
||||||
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
|
|
||||||
MEDIA_URL = '/media/'
|
|
||||||
|
|
||||||
# URL Configuration
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
ROOT_URLCONF = 'config.urls'
|
|
||||||
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
|
|
||||||
WSGI_APPLICATION = 'config.wsgi.application'
|
|
||||||
|
|
||||||
# PASSWORD STORAGE SETTINGS
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# See https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
|
|
||||||
PASSWORD_HASHERS = [
|
PASSWORD_HASHERS = [
|
||||||
|
# https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
|
||||||
'django.contrib.auth.hashers.Argon2PasswordHasher',
|
'django.contrib.auth.hashers.Argon2PasswordHasher',
|
||||||
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
||||||
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
||||||
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
||||||
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
||||||
]
|
]
|
||||||
|
|
||||||
# PASSWORD VALIDATION
|
|
||||||
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
|
@ -248,54 +129,142 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
# AUTHENTICATION CONFIGURATION
|
# MIDDLEWARE
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
AUTHENTICATION_BACKENDS = [
|
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
|
||||||
'django.contrib.auth.backends.ModelBackend',
|
MIDDLEWARE = [
|
||||||
'allauth.account.auth_backends.AuthenticationBackend',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'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',
|
||||||
]
|
]
|
||||||
|
|
||||||
# Some really nice defaults
|
# STATIC
|
||||||
ACCOUNT_AUTHENTICATION_METHOD = 'username'
|
# ------------------------------------------------------------------------------
|
||||||
ACCOUNT_EMAIL_REQUIRED = True
|
# https://docs.djangoproject.com/en/dev/ref/settings/#static-root
|
||||||
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
STATIC_ROOT = str(ROOT_DIR('staticfiles'))
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#static-url
|
||||||
|
STATIC_URL = '/static/'
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
|
||||||
|
STATICFILES_DIRS = [
|
||||||
|
str(APPS_DIR.path('static')),
|
||||||
|
]
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
|
||||||
|
STATICFILES_FINDERS = [
|
||||||
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||||
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||||
|
]
|
||||||
|
|
||||||
ACCOUNT_ALLOW_REGISTRATION = env.bool('DJANGO_ACCOUNT_ALLOW_REGISTRATION', True)
|
# MEDIA
|
||||||
ACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.AccountAdapter'
|
# ------------------------------------------------------------------------------
|
||||||
SOCIALACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.SocialAccountAdapter'
|
# https://docs.djangoproject.com/en/dev/ref/settings/#media-root
|
||||||
|
MEDIA_ROOT = str(APPS_DIR('media'))
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
|
||||||
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
# Custom user app defaults
|
# TEMPLATES
|
||||||
# Select the correct user model
|
# ------------------------------------------------------------------------------
|
||||||
AUTH_USER_MODEL = 'users.User'
|
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
||||||
LOGIN_REDIRECT_URL = 'users:redirect'
|
TEMPLATES = [
|
||||||
LOGIN_URL = 'account_login'
|
{
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
|
||||||
|
'DIRS': [
|
||||||
|
str(APPS_DIR.path('templates')),
|
||||||
|
],
|
||||||
|
'OPTIONS': {
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
|
||||||
|
'debug': DEBUG,
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
|
||||||
|
'loaders': [
|
||||||
|
'django.template.loaders.filesystem.Loader',
|
||||||
|
'django.template.loaders.app_directories.Loader',
|
||||||
|
],
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
|
||||||
|
'context_processors': [
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.request',
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.template.context_processors.i18n',
|
||||||
|
'django.template.context_processors.media',
|
||||||
|
'django.template.context_processors.static',
|
||||||
|
'django.template.context_processors.tz',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
# http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
|
||||||
|
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
||||||
|
|
||||||
# SLUGLIFIER
|
# FIXTURES
|
||||||
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
|
# ------------------------------------------------------------------------------
|
||||||
{% if cookiecutter.use_celery == 'y' %}
|
# https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs
|
||||||
########## CELERY
|
FIXTURE_DIRS = (
|
||||||
|
str(APPS_DIR.path('fixtures')),
|
||||||
|
)
|
||||||
|
|
||||||
|
# EMAIL
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
||||||
|
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
|
||||||
|
|
||||||
|
# ADMIN
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Django Admin URL regex.
|
||||||
|
ADMIN_URL = r'^admin/'
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
||||||
|
ADMINS = [
|
||||||
|
("""{{cookiecutter.author_name}}""", '{{cookiecutter.email}}'),
|
||||||
|
]
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
||||||
|
MANAGERS = ADMINS
|
||||||
|
|
||||||
|
{% if cookiecutter.use_celery == 'y' -%}
|
||||||
|
# Celery
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
INSTALLED_APPS += ['{{cookiecutter.project_slug}}.taskapp.celery.CeleryConfig']
|
INSTALLED_APPS += ['{{cookiecutter.project_slug}}.taskapp.celery.CeleryConfig']
|
||||||
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-broker_url
|
||||||
CELERY_BROKER_URL = env('CELERY_BROKER_URL', default='django://')
|
CELERY_BROKER_URL = env('CELERY_BROKER_URL', default='django://')
|
||||||
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend
|
||||||
if CELERY_BROKER_URL == 'django://':
|
if CELERY_BROKER_URL == 'django://':
|
||||||
CELERY_RESULT_BACKEND = 'redis://'
|
CELERY_RESULT_BACKEND = 'redis://'
|
||||||
else:
|
else:
|
||||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
||||||
# default to json serialization only
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content
|
||||||
CELERY_ACCEPT_CONTENT = ['json']
|
CELERY_ACCEPT_CONTENT = ['json']
|
||||||
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer
|
||||||
CELERY_TASK_SERIALIZER = 'json'
|
CELERY_TASK_SERIALIZER = 'json'
|
||||||
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_serializer
|
||||||
CELERY_RESULT_SERIALIZER = 'json'
|
CELERY_RESULT_SERIALIZER = 'json'
|
||||||
########## END CELERY
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{%- if cookiecutter.use_compressor == 'y'-%}
|
{%- endif %}
|
||||||
|
# django-allauth
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
ACCOUNT_ALLOW_REGISTRATION = env.bool('DJANGO_ACCOUNT_ALLOW_REGISTRATION', True)
|
||||||
|
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||||
|
ACCOUNT_AUTHENTICATION_METHOD = 'username'
|
||||||
|
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||||
|
ACCOUNT_EMAIL_REQUIRED = True
|
||||||
|
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||||
|
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
||||||
|
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||||
|
ACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.AccountAdapter'
|
||||||
|
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||||
|
SOCIALACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.SocialAccountAdapter'
|
||||||
|
|
||||||
|
{% if cookiecutter.use_compressor == 'y' -%}
|
||||||
# django-compressor
|
# django-compressor
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://django-compressor.readthedocs.io/en/latest/quickstart/#installation
|
||||||
INSTALLED_APPS += ['compressor']
|
INSTALLED_APPS += ['compressor']
|
||||||
STATICFILES_FINDERS += ['compressor.finders.CompressorFinder']
|
STATICFILES_FINDERS += ['compressor.finders.CompressorFinder']
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
# Your stuff...
|
||||||
# Location of root django.contrib.admin URL, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
|
||||||
ADMIN_URL = r'^admin/'
|
|
||||||
|
|
||||||
# Your common stuff: Below this line define 3rd party library settings
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,54 +1,20 @@
|
||||||
"""
|
|
||||||
Local settings for {{cookiecutter.project_name}} project.
|
|
||||||
|
|
||||||
- Run in Debug mode
|
|
||||||
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' %}
|
|
||||||
- Use mailhog for emails via Docker
|
|
||||||
{% elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' %}
|
|
||||||
- Use mailhog for emails
|
|
||||||
{% else %}
|
|
||||||
- Use console backend for emails
|
|
||||||
{% endif %}
|
|
||||||
- Add Django Debug Toolbar
|
|
||||||
- Add django-extensions as app
|
|
||||||
"""
|
|
||||||
|
|
||||||
from .base import * # noqa
|
from .base import * # noqa
|
||||||
|
|
||||||
# SITE CONFIGURATION
|
# GENERAL
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||||
|
DEBUG = env.bool('DJANGO_DEBUG', default=True)
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||||
|
SECRET_KEY = env('DJANGO_SECRET_KEY', default='!!!SET DJANGO_SECRET_KEY!!!')
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||||
ALLOWED_HOSTS = [
|
ALLOWED_HOSTS = [
|
||||||
"localhost",
|
"localhost",
|
||||||
"0.0.0.0",
|
"0.0.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
# DEBUG
|
# CACHES
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
DEBUG = env.bool('DJANGO_DEBUG', default=True)
|
|
||||||
TEMPLATES[0]['OPTIONS']['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', default='!!!SET DJANGO_SECRET_KEY!!!')
|
|
||||||
|
|
||||||
# Mail settings
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
EMAIL_PORT = 1025
|
|
||||||
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' %}
|
|
||||||
EMAIL_HOST = env('EMAIL_HOST', default='mailhog')
|
|
||||||
{% elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' %}
|
|
||||||
EMAIL_HOST = 'localhost'
|
|
||||||
{% else %}
|
|
||||||
EMAIL_HOST = 'localhost'
|
|
||||||
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND',
|
|
||||||
default='django.core.mail.backends.console.EmailBackend')
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# CACHING
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#caches
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||||
|
@ -56,40 +22,62 @@ CACHES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TEMPLATES
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
||||||
|
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||||
|
|
||||||
|
# EMAIL
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' -%}
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||||
|
EMAIL_HOST = env('EMAIL_HOST', default='mailhog')
|
||||||
|
{%- elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' -%}
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||||
|
EMAIL_HOST = 'localhost'
|
||||||
|
{%- else -%}
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
||||||
|
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.console.EmailBackend')
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||||
|
EMAIL_HOST = 'localhost'
|
||||||
|
{%- endif %}
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
|
||||||
|
EMAIL_PORT = 1025
|
||||||
|
|
||||||
# django-debug-toolbar
|
# django-debug-toolbar
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ]
|
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#prerequisites
|
||||||
INSTALLED_APPS += ['debug_toolbar', ]
|
INSTALLED_APPS += ['debug_toolbar']
|
||||||
|
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware
|
||||||
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2', ]
|
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware']
|
||||||
{% if cookiecutter.use_docker == 'y' %}
|
# https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config
|
||||||
{# [cookiecutter-django] This is a workaround to flake8 "imported but unused" errors #}
|
|
||||||
import socket
|
|
||||||
import os
|
|
||||||
# tricks to have debug toolbar when developing with docker
|
|
||||||
if os.environ.get('USE_DOCKER') == 'yes':
|
|
||||||
ip = socket.gethostbyname(socket.gethostname())
|
|
||||||
INTERNAL_IPS += [ip[:-1] + '1']
|
|
||||||
{% endif %}
|
|
||||||
DEBUG_TOOLBAR_CONFIG = {
|
DEBUG_TOOLBAR_CONFIG = {
|
||||||
'DISABLE_PANELS': [
|
'DISABLE_PANELS': [
|
||||||
'debug_toolbar.panels.redirects.RedirectsPanel',
|
'debug_toolbar.panels.redirects.RedirectsPanel',
|
||||||
],
|
],
|
||||||
'SHOW_TEMPLATE_CONTEXT': True,
|
'SHOW_TEMPLATE_CONTEXT': True,
|
||||||
}
|
}
|
||||||
|
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips
|
||||||
|
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2']
|
||||||
|
{% if cookiecutter.use_docker == 'y' -%}
|
||||||
|
import socket
|
||||||
|
import os
|
||||||
|
if os.environ.get('USE_DOCKER') == 'yes':
|
||||||
|
ip = socket.gethostbyname(socket.gethostname())
|
||||||
|
INTERNAL_IPS += [ip[:-1] + '1']
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
# django-extensions
|
# django-extensions
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
INSTALLED_APPS += ['django_extensions', ]
|
# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration
|
||||||
|
INSTALLED_APPS += ['django_extensions']
|
||||||
|
{% if cookiecutter.use_celery == 'y' -%}
|
||||||
|
|
||||||
# TESTING
|
# Celery
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_always_eager
|
||||||
{% if cookiecutter.use_celery == 'y' %}
|
|
||||||
########## CELERY
|
|
||||||
# In development, all tasks will be executed locally by blocking until the task returns
|
|
||||||
CELERY_ALWAYS_EAGER = True
|
CELERY_ALWAYS_EAGER = True
|
||||||
########## END CELERY
|
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
# Your local stuff: Below this line define 3rd party library settings
|
# Your stuff...
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,196 +1,189 @@
|
||||||
"""
|
|
||||||
Production settings for {{cookiecutter.project_name}} project.
|
|
||||||
|
|
||||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
|
||||||
- Use WhiteNoise for serving static files{% endif %}
|
|
||||||
- Use Amazon's S3 for storing {% if cookiecutter.use_whitenoise == 'n' -%}static files and {% endif %}uploaded media
|
|
||||||
- Use mailgun to send emails
|
|
||||||
- Use Redis for cache
|
|
||||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
|
||||||
- Use sentry for error logging
|
|
||||||
{% endif %}
|
|
||||||
{% if cookiecutter.use_opbeat == 'y' %}
|
|
||||||
- Use opbeat for error reporting
|
|
||||||
{% endif %}
|
|
||||||
"""
|
|
||||||
|
|
||||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
|
||||||
import logging
|
import logging
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
from .base import * # noqa
|
from .base import * # noqa
|
||||||
|
|
||||||
# SECRET CONFIGURATION
|
# GENERAL
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||||
# Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ
|
|
||||||
SECRET_KEY = env('DJANGO_SECRET_KEY')
|
SECRET_KEY = env('DJANGO_SECRET_KEY')
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||||
|
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['{{ cookiecutter.domain_name }}'])
|
||||||
|
|
||||||
|
# DATABASES
|
||||||
# This ensures that Django will be able to detect a secure connection
|
|
||||||
# properly on Heroku.
|
|
||||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
|
||||||
|
|
||||||
{%- if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
|
||||||
# raven sentry client
|
|
||||||
# See https://docs.sentry.io/clients/python/integrations/django/
|
|
||||||
INSTALLED_APPS += ['raven.contrib.django.raven_compat', ]
|
|
||||||
{% endif %}
|
|
||||||
{%- if cookiecutter.use_whitenoise == 'y' %}
|
|
||||||
# Use Whitenoise to serve static files
|
|
||||||
# See: https://whitenoise.readthedocs.io/
|
|
||||||
WHITENOISE_MIDDLEWARE = ['whitenoise.middleware.WhiteNoiseMiddleware', ]
|
|
||||||
MIDDLEWARE = WHITENOISE_MIDDLEWARE + MIDDLEWARE
|
|
||||||
{% endif %}
|
|
||||||
{%- if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
|
||||||
RAVEN_MIDDLEWARE = ['raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware']
|
|
||||||
MIDDLEWARE = RAVEN_MIDDLEWARE + MIDDLEWARE
|
|
||||||
{% endif %}
|
|
||||||
{%- if cookiecutter.use_opbeat == 'y' -%}
|
|
||||||
# opbeat integration
|
|
||||||
# See https://opbeat.com/languages/django/
|
|
||||||
INSTALLED_APPS += ['opbeat.contrib.django', ]
|
|
||||||
OPBEAT = {
|
|
||||||
'ORGANIZATION_ID': env('DJANGO_OPBEAT_ORGANIZATION_ID'),
|
|
||||||
'APP_ID': env('DJANGO_OPBEAT_APP_ID'),
|
|
||||||
'SECRET_TOKEN': env('DJANGO_OPBEAT_SECRET_TOKEN')
|
|
||||||
}
|
|
||||||
MIDDLEWARE = ['opbeat.contrib.django.middleware.OpbeatAPMMiddleware', ] + MIDDLEWARE
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# SECURITY CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# See https://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.security
|
|
||||||
# and https://docs.djangoproject.com/en/dev/howto/deployment/checklist/#run-manage-py-check-deploy
|
|
||||||
|
|
||||||
# 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_CONTENT_TYPE_NOSNIFF = env.bool(
|
|
||||||
'DJANGO_SECURE_CONTENT_TYPE_NOSNIFF', default=True)
|
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
|
||||||
SESSION_COOKIE_SECURE = True
|
|
||||||
SESSION_COOKIE_HTTPONLY = True
|
|
||||||
SECURE_SSL_REDIRECT = env.bool('DJANGO_SECURE_SSL_REDIRECT', default=True)
|
|
||||||
CSRF_COOKIE_SECURE = True
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
|
||||||
|
|
||||||
# SITE CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Hosts/domain names that are valid for this site
|
|
||||||
# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
|
||||||
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['{{cookiecutter.domain_name}}', ])
|
|
||||||
# END SITE CONFIGURATION
|
|
||||||
|
|
||||||
INSTALLED_APPS += ['gunicorn', ]
|
|
||||||
|
|
||||||
|
|
||||||
# STORAGE CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Uploaded Media Files
|
|
||||||
# ------------------------
|
|
||||||
# See: http://django-storages.readthedocs.io/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 cache settings, don't change unless you know what you're doing:
|
|
||||||
AWS_EXPIRY = 60 * 60 * 24 * 7
|
|
||||||
|
|
||||||
AWS_S3_OBJECT_PARAMETERS = {
|
|
||||||
'CacheControl': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIRY, AWS_EXPIRY),
|
|
||||||
}
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT, used for managing
|
|
||||||
# stored files.
|
|
||||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
|
||||||
MEDIA_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
|
|
||||||
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
|
||||||
{% else %}
|
|
||||||
# See:http://stackoverflow.com/questions/10390244/
|
|
||||||
from storages.backends.s3boto3 import S3Boto3Storage
|
|
||||||
StaticRootS3BotoStorage = lambda: S3Boto3Storage(location='static') # noqa
|
|
||||||
MediaRootS3BotoStorage = lambda: S3Boto3Storage(location='media', file_overwrite=False) # noqa
|
|
||||||
DEFAULT_FILE_STORAGE = 'config.settings.production.MediaRootS3BotoStorage'
|
|
||||||
|
|
||||||
MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME
|
|
||||||
{%- endif %}
|
|
||||||
|
|
||||||
# Static Assets
|
|
||||||
# ------------------------
|
|
||||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
|
||||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
|
||||||
{% else %}
|
|
||||||
STATIC_URL = 'https://s3.amazonaws.com/%s/static/' % AWS_STORAGE_BUCKET_NAME
|
|
||||||
STATICFILES_STORAGE = 'config.settings.production.StaticRootS3BotoStorage'
|
|
||||||
# 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
|
|
||||||
{%- endif %}
|
|
||||||
{% if cookiecutter.use_compressor == 'y'-%}
|
|
||||||
# COMPRESSOR
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
COMPRESS_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
|
||||||
COMPRESS_URL = STATIC_URL
|
|
||||||
COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True)
|
|
||||||
{%- endif %}
|
|
||||||
# EMAIL
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL',
|
|
||||||
default='{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>')
|
|
||||||
EMAIL_SUBJECT_PREFIX = env('DJANGO_EMAIL_SUBJECT_PREFIX', default='[{{cookiecutter.project_name}}]')
|
|
||||||
SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL)
|
|
||||||
|
|
||||||
# Anymail with Mailgun
|
|
||||||
INSTALLED_APPS += ['anymail', ]
|
|
||||||
ANYMAIL = {
|
|
||||||
'MAILGUN_API_KEY': env('MAILGUN_API_KEY'),
|
|
||||||
'MAILGUN_SENDER_DOMAIN': env('MAILGUN_DOMAIN')
|
|
||||||
}
|
|
||||||
EMAIL_BACKEND = 'anymail.backends.mailgun.EmailBackend'
|
|
||||||
|
|
||||||
# TEMPLATE CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# See:
|
|
||||||
# https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.loaders.cached.Loader
|
|
||||||
TEMPLATES[0]['OPTIONS']['loaders'] = [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ]),
|
|
||||||
]
|
|
||||||
|
|
||||||
# DATABASE CONFIGURATION
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
DATABASES['default'] = env.db('DATABASE_URL')
|
DATABASES['default'] = env.db('DATABASE_URL')
|
||||||
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
||||||
DATABASES['default']['CONN_MAX_AGE'] = env.int('CONN_MAX_AGE', default=60)
|
DATABASES['default']['CONN_MAX_AGE'] = env.int('CONN_MAX_AGE', default=60)
|
||||||
|
|
||||||
# CACHING
|
# CACHES
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
REDIS_LOCATION = '{0}/{1}'.format(env('REDIS_URL', default='redis://127.0.0.1:6379'), 0)
|
|
||||||
|
|
||||||
# Heroku URL does not pass the DB number, so we parse it in
|
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'django_redis.cache.RedisCache',
|
'BACKEND': 'django_redis.cache.RedisCache',
|
||||||
'LOCATION': REDIS_LOCATION,
|
'LOCATION': "{}/0".format(env('REDIS_URL', default='redis://127.0.0.1:6379')),
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||||
'IGNORE_EXCEPTIONS': True, # mimics memcache behavior.
|
# Mimicing memcache behavior.
|
||||||
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
|
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
|
||||||
|
'IGNORE_EXCEPTIONS': True,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
# SECURITY
|
||||||
# Sentry Configuration
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
|
||||||
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
|
||||||
|
SECURE_SSL_REDIRECT = env.bool('DJANGO_SECURE_SSL_REDIRECT', default=True)
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
|
||||||
|
SESSION_COOKIE_SECURE = True
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-httponly
|
||||||
|
SESSION_COOKIE_HTTPONLY = True
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
|
||||||
|
CSRF_COOKIE_SECURE = True
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-httponly
|
||||||
|
CSRF_COOKIE_HTTPONLY = True
|
||||||
|
# https://docs.djangoproject.com/en/dev/topics/security/#ssl-https
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-seconds
|
||||||
|
# TODO: set this to 60 seconds first and then to 518400 once you prove the former works
|
||||||
|
SECURE_HSTS_SECONDS = 60
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-include-subdomains
|
||||||
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool('DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS', default=True)
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
|
||||||
|
SECURE_HSTS_PRELOAD = env.bool('DJANGO_SECURE_HSTS_PRELOAD', default=True)
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
|
||||||
|
SECURE_CONTENT_TYPE_NOSNIFF = env.bool('DJANGO_SECURE_CONTENT_TYPE_NOSNIFF', default=True)
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-browser-xss-filter
|
||||||
|
SECURE_BROWSER_XSS_FILTER = True
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#x-frame-options
|
||||||
|
X_FRAME_OPTIONS = 'DENY'
|
||||||
|
|
||||||
|
# STORAGES
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://django-storages.readthedocs.io/en/latest/#installation
|
||||||
|
INSTALLED_APPS += ['storages']
|
||||||
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||||
|
AWS_ACCESS_KEY_ID = env('DJANGO_AWS_ACCESS_KEY_ID')
|
||||||
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||||
|
AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY')
|
||||||
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||||
|
AWS_STORAGE_BUCKET_NAME = env('DJANGO_AWS_STORAGE_BUCKET_NAME')
|
||||||
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||||
|
AWS_AUTO_CREATE_BUCKET = True
|
||||||
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||||
|
AWS_QUERYSTRING_AUTH = False
|
||||||
|
# DO NOT change these unless you know what you're doing.
|
||||||
|
_AWS_EXPIRY = 60 * 60 * 24 * 7
|
||||||
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||||
|
AWS_S3_OBJECT_PARAMETERS = {
|
||||||
|
'CacheControl': 'max-age=%d, s-maxage=%d, must-revalidate' % (_AWS_EXPIRY, _AWS_EXPIRY),
|
||||||
|
}
|
||||||
|
|
||||||
|
# STATIC
|
||||||
|
# ------------------------
|
||||||
|
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||||
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||||
|
{%- else %}
|
||||||
|
STATICFILES_STORAGE = 'config.settings.production.StaticRootS3BotoStorage'
|
||||||
|
STATIC_URL = 'https://s3.amazonaws.com/%s/static/' % AWS_STORAGE_BUCKET_NAME
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
# MEDIA
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||||
|
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||||
|
MEDIA_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
|
||||||
|
{%- else %}
|
||||||
|
# region http://stackoverflow.com/questions/10390244/
|
||||||
|
from storages.backends.s3boto3 import S3Boto3Storage
|
||||||
|
StaticRootS3BotoStorage = lambda: S3Boto3Storage(location='static') # noqa
|
||||||
|
MediaRootS3BotoStorage = lambda: S3Boto3Storage(location='media', file_overwrite=False) # noqa
|
||||||
|
# endregion
|
||||||
|
DEFAULT_FILE_STORAGE = 'config.settings.production.MediaRootS3BotoStorage'
|
||||||
|
MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
# TEMPLATES
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
||||||
|
TEMPLATES[0]['OPTIONS']['loaders'] = [
|
||||||
|
(
|
||||||
|
'django.template.loaders.cached.Loader',
|
||||||
|
[
|
||||||
|
'django.template.loaders.filesystem.Loader',
|
||||||
|
'django.template.loaders.app_directories.Loader',
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
# EMAIL
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email
|
||||||
|
DEFAULT_FROM_EMAIL = env(
|
||||||
|
'DJANGO_DEFAULT_FROM_EMAIL',
|
||||||
|
default='{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>'
|
||||||
|
)
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#server-email
|
||||||
|
SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL)
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
|
||||||
|
EMAIL_SUBJECT_PREFIX = env('DJANGO_EMAIL_SUBJECT_PREFIX', default='[{{cookiecutter.project_name}}]')
|
||||||
|
|
||||||
|
# ADMIN
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Django Admin URL regex.
|
||||||
|
ADMIN_URL = env('DJANGO_ADMIN_URL')
|
||||||
|
|
||||||
|
# Anymail (Mailgun)
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail
|
||||||
|
INSTALLED_APPS += ['anymail']
|
||||||
|
EMAIL_BACKEND = 'anymail.backends.mailgun.EmailBackend'
|
||||||
|
# https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference
|
||||||
|
ANYMAIL = {
|
||||||
|
'MAILGUN_API_KEY': env('MAILGUN_API_KEY'),
|
||||||
|
'MAILGUN_SENDER_DOMAIN': env('MAILGUN_DOMAIN')
|
||||||
|
}
|
||||||
|
|
||||||
|
# Gunicorn
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
INSTALLED_APPS += ['gunicorn']
|
||||||
|
|
||||||
|
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||||
|
# WhiteNoise
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# http://whitenoise.evans.io/en/latest/django.html#enable-whitenoise
|
||||||
|
MIDDLEWARE = ['whitenoise.middleware.WhiteNoiseMiddleware'] + MIDDLEWARE
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
|
{% if cookiecutter.use_compressor == 'y' -%}
|
||||||
|
# django-compressor
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
|
||||||
|
COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True)
|
||||||
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
|
||||||
|
COMPRESS_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||||
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_URL
|
||||||
|
COMPRESS_URL = STATIC_URL
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
|
{% if cookiecutter.use_whitenoise == 'n' -%}
|
||||||
|
# Collectfast
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://github.com/antonagestam/collectfast#installation
|
||||||
|
INSTALLED_APPS = ['collectfast'] + INSTALLED_APPS
|
||||||
|
AWS_PRELOAD_METADATA = True
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
|
{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||||
|
# raven
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.sentry.io/clients/python/integrations/django/
|
||||||
|
INSTALLED_APPS += ['raven.contrib.django.raven_compat']
|
||||||
|
MIDDLEWARE = ['raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware'] + MIDDLEWARE
|
||||||
|
|
||||||
|
# Sentry
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
SENTRY_DSN = env('DJANGO_SENTRY_DSN')
|
SENTRY_DSN = env('DJANGO_SENTRY_DSN')
|
||||||
SENTRY_CLIENT = env('DJANGO_SENTRY_CLIENT', default='raven.contrib.django.raven_compat.DjangoClient')
|
SENTRY_CLIENT = env('DJANGO_SENTRY_CLIENT', default='raven.contrib.django.raven_compat.DjangoClient')
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
|
@ -198,7 +191,7 @@ LOGGING = {
|
||||||
'disable_existing_loggers': True,
|
'disable_existing_loggers': True,
|
||||||
'root': {
|
'root': {
|
||||||
'level': 'WARNING',
|
'level': 'WARNING',
|
||||||
'handlers': ['sentry', ],
|
'handlers': ['sentry'],
|
||||||
},
|
},
|
||||||
'formatters': {
|
'formatters': {
|
||||||
'verbose': {
|
'verbose': {
|
||||||
|
@ -220,38 +213,39 @@ LOGGING = {
|
||||||
'loggers': {
|
'loggers': {
|
||||||
'django.db.backends': {
|
'django.db.backends': {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
'handlers': ['console', ],
|
'handlers': ['console'],
|
||||||
'propagate': False,
|
'propagate': False,
|
||||||
},
|
},
|
||||||
'raven': {
|
'raven': {
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
'handlers': ['console', ],
|
'handlers': ['console'],
|
||||||
'propagate': False,
|
'propagate': False,
|
||||||
},
|
},
|
||||||
'sentry.errors': {
|
'sentry.errors': {
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
'handlers': ['console', ],
|
'handlers': ['console'],
|
||||||
'propagate': False,
|
'propagate': False,
|
||||||
},
|
},
|
||||||
'django.security.DisallowedHost': {
|
'django.security.DisallowedHost': {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
'handlers': ['console', 'sentry', ],
|
'handlers': ['console', 'sentry'],
|
||||||
'propagate': False,
|
'propagate': False,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
SENTRY_CELERY_LOGLEVEL = env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO)
|
SENTRY_CELERY_LOGLEVEL = env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO)
|
||||||
RAVEN_CONFIG = {
|
RAVEN_CONFIG = {
|
||||||
'CELERY_LOGLEVEL': env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO),
|
'CELERY_LOGLEVEL': env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO),
|
||||||
'DSN': SENTRY_DSN
|
'DSN': SENTRY_DSN
|
||||||
}
|
}
|
||||||
{% elif cookiecutter.use_sentry_for_error_reporting == 'n' %}
|
{%- else %}
|
||||||
# LOGGING CONFIGURATION
|
# LOGGING
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
||||||
# A sample logging configuration. The only tangible logging
|
# A sample logging configuration. The only tangible logging
|
||||||
# performed by this configuration is to send an email to
|
# performed by this configuration is to send an email to
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
# the site admins bon every HTTP 500 error when DEBUG=False.
|
||||||
# See https://docs.djangoproject.com/en/dev/topics/logging for
|
# See https://docs.djangoproject.com/en/dev/topics/logging for
|
||||||
# more details on how to customize your logging configuration.
|
# more details on how to customize your logging configuration.
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
|
@ -271,7 +265,7 @@ LOGGING = {
|
||||||
'handlers': {
|
'handlers': {
|
||||||
'mail_admins': {
|
'mail_admins': {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
'filters': ['require_debug_false', ],
|
'filters': ['require_debug_false'],
|
||||||
'class': 'django.utils.log.AdminEmailHandler'
|
'class': 'django.utils.log.AdminEmailHandler'
|
||||||
},
|
},
|
||||||
'console': {
|
'console': {
|
||||||
|
@ -282,20 +276,33 @@ LOGGING = {
|
||||||
},
|
},
|
||||||
'loggers': {
|
'loggers': {
|
||||||
'django.request': {
|
'django.request': {
|
||||||
'handlers': ['mail_admins', ],
|
'handlers': ['mail_admins'],
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
'propagate': True
|
'propagate': True
|
||||||
},
|
},
|
||||||
'django.security.DisallowedHost': {
|
'django.security.DisallowedHost': {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
'handlers': ['console', 'mail_admins', ],
|
'handlers': ['console', 'mail_admins'],
|
||||||
'propagate': True
|
'propagate': True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{% endif %}
|
|
||||||
# Custom Admin URL, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
|
||||||
ADMIN_URL = env('DJANGO_ADMIN_URL')
|
|
||||||
|
|
||||||
# Your production stuff: Below this line define 3rd party library settings
|
{%- endif %}
|
||||||
|
{% if cookiecutter.use_opbeat == 'y' -%}
|
||||||
|
# opbeat
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://opbeat.com/docs/articles/get-started-with-django/#setup
|
||||||
|
INSTALLED_APPS += ['opbeat.contrib.django']
|
||||||
|
# https://opbeat.com/docs/articles/get-started-with-django/#setup
|
||||||
|
OPBEAT = {
|
||||||
|
'ORGANIZATION_ID': env('DJANGO_OPBEAT_ORGANIZATION_ID'),
|
||||||
|
'APP_ID': env('DJANGO_OPBEAT_APP_ID'),
|
||||||
|
'SECRET_TOKEN': env('DJANGO_OPBEAT_SECRET_TOKEN')
|
||||||
|
}
|
||||||
|
# https://opbeat.com/docs/articles/get-started-with-django/#performance-metrics
|
||||||
|
MIDDLEWARE = ['opbeat.contrib.django.middleware.OpbeatAPMMiddleware'] + MIDDLEWARE
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
|
# Your stuff...
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,36 +1,21 @@
|
||||||
"""
|
"""
|
||||||
Test settings for {{cookiecutter.project_name}} project.
|
With these settings, tests run faster.
|
||||||
|
|
||||||
- Used to run tests fast on the continuous integration server and locally
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .base import * # noqa
|
from .base import * # noqa
|
||||||
|
|
||||||
|
# GENERAL
|
||||||
# DEBUG
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Turn debug off so tests run faster
|
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
TEMPLATES[0]['OPTIONS']['debug'] = False
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||||
|
|
||||||
# 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', default='!!!SET DJANGO_SECRET_KEY!!!')
|
SECRET_KEY = env('DJANGO_SECRET_KEY', default='!!!SET DJANGO_SECRET_KEY!!!')
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#test-runner
|
||||||
|
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
||||||
|
|
||||||
# Mail settings
|
# CACHES
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
EMAIL_HOST = 'localhost'
|
# https://docs.djangoproject.com/en/dev/ref/settings/#caches
|
||||||
EMAIL_PORT = 1025
|
|
||||||
|
|
||||||
# In-memory email backend stores messages in django.core.mail.outbox
|
|
||||||
# for unit testing purposes
|
|
||||||
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
|
|
||||||
|
|
||||||
# CACHING
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Speed advantages of in-memory caching without having to run Memcached
|
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||||
|
@ -38,24 +23,35 @@ CACHES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# TESTING
|
# PASSWORDS
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
|
||||||
|
|
||||||
|
|
||||||
# PASSWORD HASHING
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Use fast password hasher so tests run faster
|
|
||||||
PASSWORD_HASHERS = [
|
PASSWORD_HASHERS = [
|
||||||
'django.contrib.auth.hashers.MD5PasswordHasher',
|
'django.contrib.auth.hashers.MD5PasswordHasher',
|
||||||
]
|
]
|
||||||
|
|
||||||
# TEMPLATE LOADERS
|
# TEMPLATES
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Keep templates in memory so tests run faster
|
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
||||||
|
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||||
TEMPLATES[0]['OPTIONS']['loaders'] = [
|
TEMPLATES[0]['OPTIONS']['loaders'] = [
|
||||||
['django.template.loaders.cached.Loader', [
|
(
|
||||||
'django.template.loaders.filesystem.Loader',
|
'django.template.loaders.cached.Loader',
|
||||||
'django.template.loaders.app_directories.Loader',
|
[
|
||||||
], ],
|
'django.template.loaders.filesystem.Loader',
|
||||||
|
'django.template.loaders.app_directories.Loader',
|
||||||
|
],
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# EMAIL
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
||||||
|
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||||
|
EMAIL_HOST = 'localhost'
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
|
||||||
|
EMAIL_PORT = 1025
|
||||||
|
|
||||||
|
# Your stuff...
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user