2020-03-03 22:53:15 +03:00
|
|
|
"""isort:skip_file"""
|
2018-05-09 13:42:20 +03:00
|
|
|
{% if cookiecutter.use_sentry == 'y' -%}
|
|
|
|
import logging
|
|
|
|
|
2019-03-20 13:04:44 +03:00
|
|
|
import sentry_sdk
|
|
|
|
|
|
|
|
from sentry_sdk.integrations.django import DjangoIntegration
|
|
|
|
from sentry_sdk.integrations.logging import LoggingIntegration
|
|
|
|
{%- if cookiecutter.use_celery == 'y' %}
|
|
|
|
from sentry_sdk.integrations.celery import CeleryIntegration
|
|
|
|
{% endif %}
|
|
|
|
|
2018-05-09 13:42:20 +03:00
|
|
|
{% endif -%}
|
2017-01-17 06:38:52 +03:00
|
|
|
from .base import * # noqa
|
2018-03-06 19:56:27 +03:00
|
|
|
from .base import env
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# GENERAL
|
2015-04-25 16:29:33 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
2019-03-18 20:49:43 +03:00
|
|
|
SECRET_KEY = env("DJANGO_SECRET_KEY")
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
2019-03-18 20:49:43 +03:00
|
|
|
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["{{ cookiecutter.domain_name }}"])
|
2015-04-25 16:29:33 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# DATABASES
|
|
|
|
# ------------------------------------------------------------------------------
|
2019-03-18 20:49:43 +03:00
|
|
|
DATABASES["default"] = env.db("DATABASE_URL") # noqa F405
|
|
|
|
DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa F405
|
|
|
|
DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60) # noqa F405
|
2016-06-04 02:07:27 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# CACHES
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
CACHES = {
|
2019-03-18 20:49:43 +03:00
|
|
|
"default": {
|
|
|
|
"BACKEND": "django_redis.cache.RedisCache",
|
|
|
|
"LOCATION": env("REDIS_URL"),
|
|
|
|
"OPTIONS": {
|
|
|
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
2018-03-06 14:28:25 +03:00
|
|
|
# Mimicing memcache behavior.
|
|
|
|
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
|
2019-03-18 20:49:43 +03:00
|
|
|
"IGNORE_EXCEPTIONS": True,
|
|
|
|
},
|
2018-03-06 14:28:25 +03:00
|
|
|
}
|
2015-11-16 18:55:37 +03:00
|
|
|
}
|
2016-06-04 02:07:27 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# SECURITY
|
2016-06-04 02:07:27 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
|
2019-03-18 20:49:43 +03:00
|
|
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
|
2019-03-18 20:49:43 +03:00
|
|
|
SECURE_SSL_REDIRECT = env.bool("DJANGO_SECURE_SSL_REDIRECT", default=True)
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
|
2016-06-04 02:07:27 +03:00
|
|
|
SESSION_COOKIE_SECURE = True
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
|
2016-06-04 02:07:27 +03:00
|
|
|
CSRF_COOKIE_SECURE = True
|
2018-03-06 14:28:25 +03:00
|
|
|
# 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
|
2019-03-18 20:49:43 +03:00
|
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool(
|
|
|
|
"DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True
|
|
|
|
)
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
|
2019-03-18 20:49:43 +03:00
|
|
|
SECURE_HSTS_PRELOAD = env.bool("DJANGO_SECURE_HSTS_PRELOAD", default=True)
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
|
2019-03-18 20:49:43 +03:00
|
|
|
SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
|
|
|
|
"DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True
|
|
|
|
)
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2019-05-27 17:55:41 +03:00
|
|
|
{% if cookiecutter.cloud_provider != 'None' -%}
|
2018-03-06 14:28:25 +03:00
|
|
|
# STORAGES
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://django-storages.readthedocs.io/en/latest/#installation
|
2019-04-06 22:04:22 +03:00
|
|
|
INSTALLED_APPS += ["storages"] # noqa F405
|
2019-05-19 02:23:48 +03:00
|
|
|
{%- endif -%}
|
2019-04-02 09:13:31 +03:00
|
|
|
{% if cookiecutter.cloud_provider == 'AWS' %}
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
2019-03-18 20:49:43 +03:00
|
|
|
AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID")
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
2019-03-18 20:49:43 +03:00
|
|
|
AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY")
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
2019-03-18 20:49:43 +03:00
|
|
|
AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
2015-04-20 00:09:00 +03:00
|
|
|
AWS_QUERYSTRING_AUTH = False
|
2018-03-06 14:28:25 +03:00
|
|
|
# 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
|
2018-02-13 18:04:43 +03:00
|
|
|
AWS_S3_OBJECT_PARAMETERS = {
|
2019-03-18 20:49:43 +03:00
|
|
|
"CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate"
|
2015-04-20 00:09:00 +03:00
|
|
|
}
|
2019-03-19 22:57:31 +03:00
|
|
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
|
|
|
AWS_DEFAULT_ACL = None
|
2019-04-02 16:43:48 +03:00
|
|
|
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
|
|
|
AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None)
|
2019-05-19 02:24:29 +03:00
|
|
|
{% elif cookiecutter.cloud_provider == 'GCP' %}
|
|
|
|
GS_BUCKET_NAME = env("DJANGO_GCP_STORAGE_BUCKET_NAME")
|
2019-04-06 22:04:22 +03:00
|
|
|
GS_DEFAULT_ACL = "publicRead"
|
2019-05-27 18:33:07 +03:00
|
|
|
{% endif -%}
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2019-05-27 18:33:07 +03:00
|
|
|
{% if cookiecutter.cloud_provider != 'None' or cookiecutter.use_whitenoise == 'y' -%}
|
2018-03-06 14:28:25 +03:00
|
|
|
# STATIC
|
|
|
|
# ------------------------
|
2019-05-27 18:33:07 +03:00
|
|
|
{% endif -%}
|
2018-03-06 14:28:25 +03:00
|
|
|
{% if cookiecutter.use_whitenoise == 'y' -%}
|
2019-03-18 20:49:43 +03:00
|
|
|
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
2019-05-27 17:55:41 +03:00
|
|
|
{% elif cookiecutter.cloud_provider == 'AWS' -%}
|
2019-04-06 22:04:22 +03:00
|
|
|
STATICFILES_STORAGE = "config.settings.production.StaticRootS3Boto3Storage"
|
2019-10-22 05:20:00 +03:00
|
|
|
COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy"
|
2019-04-06 22:04:22 +03:00
|
|
|
STATIC_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/static/"
|
2019-05-19 02:24:29 +03:00
|
|
|
{% elif cookiecutter.cloud_provider == 'GCP' -%}
|
2019-10-04 15:32:25 +03:00
|
|
|
STATICFILES_STORAGE = "config.settings.production.StaticRootGoogleCloudStorage"
|
2019-10-22 05:20:00 +03:00
|
|
|
COLLECTFAST_STRATEGY = "collectfast.strategies.gcloud.GoogleCloudStrategy"
|
2019-05-27 17:58:56 +03:00
|
|
|
STATIC_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/static/"
|
2019-05-27 18:33:07 +03:00
|
|
|
{% endif -%}
|
2018-03-06 14:28:25 +03:00
|
|
|
|
|
|
|
# MEDIA
|
|
|
|
# ------------------------------------------------------------------------------
|
2019-04-02 09:13:31 +03:00
|
|
|
{%- if cookiecutter.cloud_provider == 'AWS' %}
|
2018-03-06 14:28:25 +03:00
|
|
|
# region http://stackoverflow.com/questions/10390244/
|
2018-09-01 09:40:57 +03:00
|
|
|
# Full-fledge class: https://stackoverflow.com/a/18046120/104731
|
2018-05-21 21:57:31 +03:00
|
|
|
from storages.backends.s3boto3 import S3Boto3Storage # noqa E402
|
2018-09-01 09:40:57 +03:00
|
|
|
|
|
|
|
|
2018-09-09 14:59:04 +03:00
|
|
|
class StaticRootS3Boto3Storage(S3Boto3Storage):
|
2019-03-18 20:49:43 +03:00
|
|
|
location = "static"
|
2019-05-18 16:06:05 +03:00
|
|
|
default_acl = "public-read"
|
2018-09-01 09:40:57 +03:00
|
|
|
|
|
|
|
|
2018-09-09 14:59:04 +03:00
|
|
|
class MediaRootS3Boto3Storage(S3Boto3Storage):
|
2019-03-18 20:49:43 +03:00
|
|
|
location = "media"
|
2018-09-01 09:40:57 +03:00
|
|
|
file_overwrite = False
|
|
|
|
|
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# endregion
|
2019-03-18 20:49:43 +03:00
|
|
|
DEFAULT_FILE_STORAGE = "config.settings.production.MediaRootS3Boto3Storage"
|
|
|
|
MEDIA_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/media/"
|
2019-05-19 02:24:29 +03:00
|
|
|
{%- elif cookiecutter.cloud_provider == 'GCP' %}
|
2019-10-04 15:32:25 +03:00
|
|
|
from storages.backends.gcloud import GoogleCloudStorage # noqa E402
|
|
|
|
|
|
|
|
|
|
|
|
class StaticRootGoogleCloudStorage(GoogleCloudStorage):
|
|
|
|
location = "static"
|
|
|
|
default_acl = "publicRead"
|
|
|
|
|
|
|
|
|
|
|
|
class MediaRootGoogleCloudStorage(GoogleCloudStorage):
|
|
|
|
location = "media"
|
|
|
|
file_overwrite = False
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_FILE_STORAGE = "config.settings.production.MediaRootGoogleCloudStorage"
|
2019-05-27 17:58:56 +03:00
|
|
|
MEDIA_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/"
|
2016-03-02 17:49:34 +03:00
|
|
|
{%- endif %}
|
2015-04-26 12:57:45 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# TEMPLATES
|
2016-06-18 05:07:45 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
2020-01-14 17:50:38 +03:00
|
|
|
TEMPLATES[-1]["OPTIONS"]["loaders"] = [ # type: ignore[index] # noqa F405
|
2018-03-06 14:28:25 +03:00
|
|
|
(
|
2019-03-18 20:49:43 +03:00
|
|
|
"django.template.loaders.cached.Loader",
|
2018-03-06 14:28:25 +03:00
|
|
|
[
|
2019-03-18 20:49:43 +03:00
|
|
|
"django.template.loaders.filesystem.Loader",
|
|
|
|
"django.template.loaders.app_directories.Loader",
|
|
|
|
],
|
|
|
|
)
|
2018-03-06 14:28:25 +03:00
|
|
|
]
|
|
|
|
|
2015-04-20 00:09:00 +03:00
|
|
|
# EMAIL
|
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email
|
|
|
|
DEFAULT_FROM_EMAIL = env(
|
2019-03-18 20:49:43 +03:00
|
|
|
"DJANGO_DEFAULT_FROM_EMAIL", default="{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>"
|
2018-03-06 14:28:25 +03:00
|
|
|
)
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#server-email
|
2019-03-18 20:49:43 +03:00
|
|
|
SERVER_EMAIL = env("DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
|
2019-03-18 20:49:43 +03:00
|
|
|
EMAIL_SUBJECT_PREFIX = env(
|
|
|
|
"DJANGO_EMAIL_SUBJECT_PREFIX", default="[{{cookiecutter.project_name}}]"
|
|
|
|
)
|
2018-03-06 14:28:25 +03:00
|
|
|
|
|
|
|
# ADMIN
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Django Admin URL regex.
|
2019-03-18 20:49:43 +03:00
|
|
|
ADMIN_URL = env("DJANGO_ADMIN_URL")
|
2016-05-27 21:31:30 +03:00
|
|
|
|
2020-02-07 00:58:15 +03:00
|
|
|
# Anymail
|
2018-03-06 14:28:25 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail
|
2019-03-18 20:49:43 +03:00
|
|
|
INSTALLED_APPS += ["anymail"] # noqa F405
|
2020-03-14 20:43:37 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference
|
2020-03-14 20:43:37 +03:00
|
|
|
{%- if cookiecutter.mail_service == 'Mailgun' %}
|
|
|
|
# https://anymail.readthedocs.io/en/stable/esps/mailgun/
|
|
|
|
EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
|
2016-05-27 21:31:30 +03:00
|
|
|
ANYMAIL = {
|
2019-03-18 20:49:43 +03:00
|
|
|
"MAILGUN_API_KEY": env("MAILGUN_API_KEY"),
|
|
|
|
"MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"),
|
2019-04-02 16:08:51 +03:00
|
|
|
"MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"),
|
2016-05-27 21:31:30 +03:00
|
|
|
}
|
2020-03-14 20:43:37 +03:00
|
|
|
{%- elif cookiecutter.mail_service == 'Amazon SES' %}
|
|
|
|
# https://anymail.readthedocs.io/en/stable/esps/amazon_ses/
|
|
|
|
EMAIL_BACKEND = "anymail.backends.amazon_ses.EmailBackend"
|
|
|
|
ANYMAIL = {}
|
|
|
|
{%- elif cookiecutter.mail_service == 'Mailjet' %}
|
|
|
|
# https://anymail.readthedocs.io/en/stable/esps/mailjet/
|
|
|
|
EMAIL_BACKEND = "anymail.backends.mailjet.EmailBackend"
|
|
|
|
ANYMAIL = {
|
2020-02-07 00:58:15 +03:00
|
|
|
"MAILJET_API_KEY": env("MAILJET_API_KEY"),
|
|
|
|
"MAILJET_SECRET_KEY": env("MAILJET_SECRET_KEY"),
|
2020-03-14 22:09:05 +03:00
|
|
|
"MAILJET_API_URL": env("MAILJET_API_URL", default="https://api.mailjet.com/v3"),
|
2020-03-14 20:43:37 +03:00
|
|
|
}
|
|
|
|
{%- elif cookiecutter.mail_service == 'Mandrill' %}
|
|
|
|
# https://anymail.readthedocs.io/en/stable/esps/mandrill/
|
|
|
|
EMAIL_BACKEND = "anymail.backends.mandrill.EmailBackend"
|
|
|
|
ANYMAIL = {
|
2020-02-07 00:58:15 +03:00
|
|
|
"MANDRILL_API_KEY": env("MANDRILL_API_KEY"),
|
2020-02-07 04:18:49 +03:00
|
|
|
"MANDRILL_API_URL": env(
|
2020-03-14 22:09:05 +03:00
|
|
|
"MANDRILL_API_URL", default="https://mandrillapp.com/api/1.0"
|
2020-02-07 04:18:49 +03:00
|
|
|
),
|
2020-03-14 20:43:37 +03:00
|
|
|
}
|
|
|
|
{%- elif cookiecutter.mail_service == 'Postmark' %}
|
|
|
|
# https://anymail.readthedocs.io/en/stable/esps/postmark/
|
|
|
|
EMAIL_BACKEND = "anymail.backends.postmark.EmailBackend"
|
|
|
|
ANYMAIL = {
|
2020-02-07 00:58:15 +03:00
|
|
|
"POSTMARK_SERVER_TOKEN": env("POSTMARK_SERVER_TOKEN"),
|
2020-03-14 22:09:05 +03:00
|
|
|
"POSTMARK_API_URL": env("POSTMARK_API_URL", default="https://api.postmarkapp.com/"),
|
2020-03-14 20:43:37 +03:00
|
|
|
}
|
|
|
|
{%- elif cookiecutter.mail_service == 'Sendgrid' %}
|
|
|
|
# https://anymail.readthedocs.io/en/stable/esps/sendgrid/
|
|
|
|
EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend"
|
|
|
|
ANYMAIL = {
|
2020-02-07 00:58:15 +03:00
|
|
|
"SENDGRID_API_KEY": env("SENDGRID_API_KEY"),
|
|
|
|
"SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID"),
|
|
|
|
"SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"),
|
2020-03-14 22:09:05 +03:00
|
|
|
"SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"),
|
2020-03-14 20:43:37 +03:00
|
|
|
}
|
|
|
|
{%- elif cookiecutter.mail_service == 'SendinBlue' %}
|
|
|
|
# https://anymail.readthedocs.io/en/stable/esps/sendinblue/
|
|
|
|
EMAIL_BACKEND = "anymail.backends.sendinblue.EmailBackend"
|
|
|
|
ANYMAIL = {
|
2020-02-07 00:58:15 +03:00
|
|
|
"SENDINBLUE_API_KEY": env("SENDINBLUE_API_KEY"),
|
2020-02-07 04:18:49 +03:00
|
|
|
"SENDINBLUE_API_URL": env(
|
2020-03-14 22:09:05 +03:00
|
|
|
"SENDINBLUE_API_URL", default="https://api.sendinblue.com/v3/"
|
2020-02-07 04:18:49 +03:00
|
|
|
),
|
2020-03-14 20:43:37 +03:00
|
|
|
}
|
|
|
|
{%- elif cookiecutter.mail_service == 'SparkPost' %}
|
|
|
|
# https://anymail.readthedocs.io/en/stable/esps/sparkpost/
|
|
|
|
EMAIL_BACKEND = "anymail.backends.sparkpost.EmailBackend"
|
|
|
|
ANYMAIL = {
|
2020-02-07 00:58:15 +03:00
|
|
|
"SPARKPOST_API_KEY": env("SPARKPOST_API_KEY"),
|
2020-02-07 04:18:49 +03:00
|
|
|
"SPARKPOST_API_URL": env(
|
2020-03-14 22:09:05 +03:00
|
|
|
"SPARKPOST_API_URL", default="https://api.sparkpost.com/api/v1"
|
2020-02-07 04:18:49 +03:00
|
|
|
),
|
2016-05-27 21:31:30 +03:00
|
|
|
}
|
2020-03-14 20:43:37 +03:00
|
|
|
{%- elif cookiecutter.mail_service == 'Other SMTP' %}
|
|
|
|
# https://anymail.readthedocs.io/en/stable/esps
|
|
|
|
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
|
|
|
ANYMAIL = {}
|
|
|
|
{%- endif %}
|
2016-05-27 21:31:30 +03:00
|
|
|
|
2019-11-07 13:59:23 +03:00
|
|
|
{% if cookiecutter.use_compressor == 'y' -%}
|
2018-03-06 14:28:25 +03:00
|
|
|
# django-compressor
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
|
2019-03-18 20:49:43 +03:00
|
|
|
COMPRESS_ENABLED = env.bool("COMPRESS_ENABLED", default=True)
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
|
2020-02-11 23:17:50 +03:00
|
|
|
{%- if cookiecutter.cloud_provider == 'AWS' %}
|
2019-03-18 20:49:43 +03:00
|
|
|
COMPRESS_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
|
2020-02-11 23:17:50 +03:00
|
|
|
{%- elif cookiecutter.cloud_provider == 'GCP' %}
|
|
|
|
COMPRESS_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
|
|
|
|
{%- elif cookiecutter.cloud_provider == 'None' %}
|
|
|
|
COMPRESS_STORAGE = "compressor.storage.GzipCompressorFileStorage"
|
|
|
|
{%- endif %}
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_URL
|
2019-05-19 02:23:48 +03:00
|
|
|
COMPRESS_URL = STATIC_URL{% if cookiecutter.use_whitenoise == 'y' or cookiecutter.cloud_provider == 'None' %} # noqa F405{% endif %}
|
2020-02-11 23:17:50 +03:00
|
|
|
{%- if cookiecutter.use_whitenoise == 'y' %}
|
|
|
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
|
|
|
|
COMPRESS_OFFLINE = True # Offline compression is required when using Whitenoise
|
|
|
|
{%- endif %}
|
|
|
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_FILTERS
|
|
|
|
COMPRESS_FILTERS = {
|
|
|
|
"css": [
|
|
|
|
"compressor.filters.css_default.CssAbsoluteFilter",
|
|
|
|
"compressor.filters.cssmin.rCSSMinFilter",
|
|
|
|
],
|
|
|
|
"js": ["compressor.filters.jsmin.JSMinFilter"],
|
|
|
|
}
|
2018-05-21 21:57:52 +03:00
|
|
|
{% endif %}
|
|
|
|
{%- if cookiecutter.use_whitenoise == 'n' -%}
|
2018-03-06 14:28:25 +03:00
|
|
|
# Collectfast
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://github.com/antonagestam/collectfast#installation
|
2019-03-18 20:49:43 +03:00
|
|
|
INSTALLED_APPS = ["collectfast"] + INSTALLED_APPS # noqa F405
|
2018-05-21 21:57:52 +03:00
|
|
|
{% endif %}
|
2019-03-20 13:04:44 +03:00
|
|
|
# LOGGING
|
2018-03-06 14:28:25 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2019-03-20 13:04:44 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
|
|
|
# See https://docs.djangoproject.com/en/dev/topics/logging for
|
|
|
|
# more details on how to customize your logging configuration.
|
|
|
|
{% if cookiecutter.use_sentry == 'n' -%}
|
|
|
|
# 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.
|
2015-07-27 18:42:23 +03:00
|
|
|
LOGGING = {
|
2019-03-18 20:49:43 +03:00
|
|
|
"version": 1,
|
2019-03-20 13:04:44 +03:00
|
|
|
"disable_existing_loggers": False,
|
|
|
|
"filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
|
2019-03-18 20:49:43 +03:00
|
|
|
"formatters": {
|
|
|
|
"verbose": {
|
|
|
|
"format": "%(levelname)s %(asctime)s %(module)s "
|
|
|
|
"%(process)d %(thread)d %(message)s"
|
|
|
|
}
|
2015-07-27 18:42:23 +03:00
|
|
|
},
|
2019-03-18 20:49:43 +03:00
|
|
|
"handlers": {
|
2019-03-20 13:04:44 +03:00
|
|
|
"mail_admins": {
|
2019-03-18 20:49:43 +03:00
|
|
|
"level": "ERROR",
|
2019-03-20 13:04:44 +03:00
|
|
|
"filters": ["require_debug_false"],
|
|
|
|
"class": "django.utils.log.AdminEmailHandler",
|
2019-03-18 20:49:43 +03:00
|
|
|
},
|
|
|
|
"console": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"class": "logging.StreamHandler",
|
|
|
|
"formatter": "verbose",
|
2015-07-27 18:42:23 +03:00
|
|
|
},
|
|
|
|
},
|
2019-04-12 18:59:34 +03:00
|
|
|
"root": {"level": "INFO", "handlers": ["console"]},
|
2019-03-18 20:49:43 +03:00
|
|
|
"loggers": {
|
2019-03-20 13:04:44 +03:00
|
|
|
"django.request": {
|
|
|
|
"handlers": ["mail_admins"],
|
2019-03-18 20:49:43 +03:00
|
|
|
"level": "ERROR",
|
2019-03-20 13:04:44 +03:00
|
|
|
"propagate": True,
|
2015-07-27 18:42:23 +03:00
|
|
|
},
|
2019-03-18 20:49:43 +03:00
|
|
|
"django.security.DisallowedHost": {
|
|
|
|
"level": "ERROR",
|
2019-03-20 13:04:44 +03:00
|
|
|
"handlers": ["console", "mail_admins"],
|
|
|
|
"propagate": True,
|
2015-09-02 23:59:40 +03:00
|
|
|
},
|
2015-07-27 18:42:23 +03:00
|
|
|
},
|
|
|
|
}
|
2019-03-20 13:04:44 +03:00
|
|
|
{% else %}
|
2015-10-26 01:30:36 +03:00
|
|
|
LOGGING = {
|
2019-03-18 20:49:43 +03:00
|
|
|
"version": 1,
|
2019-03-20 13:04:44 +03:00
|
|
|
"disable_existing_loggers": True,
|
2019-03-18 20:49:43 +03:00
|
|
|
"formatters": {
|
|
|
|
"verbose": {
|
|
|
|
"format": "%(levelname)s %(asctime)s %(module)s "
|
|
|
|
"%(process)d %(thread)d %(message)s"
|
2015-10-26 01:30:36 +03:00
|
|
|
}
|
|
|
|
},
|
2019-03-18 20:49:43 +03:00
|
|
|
"handlers": {
|
|
|
|
"console": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"class": "logging.StreamHandler",
|
|
|
|
"formatter": "verbose",
|
2019-03-20 13:04:44 +03:00
|
|
|
}
|
2015-10-26 01:30:36 +03:00
|
|
|
},
|
2019-04-12 18:59:34 +03:00
|
|
|
"root": {"level": "INFO", "handlers": ["console"]},
|
2019-03-18 20:49:43 +03:00
|
|
|
"loggers": {
|
2019-03-20 13:04:44 +03:00
|
|
|
"django.db.backends": {
|
2019-03-18 20:49:43 +03:00
|
|
|
"level": "ERROR",
|
2019-03-20 13:04:44 +03:00
|
|
|
"handlers": ["console"],
|
|
|
|
"propagate": False,
|
2015-10-26 01:30:36 +03:00
|
|
|
},
|
2019-03-20 13:04:44 +03:00
|
|
|
# Errors logged by the SDK itself
|
|
|
|
"sentry_sdk": {"level": "ERROR", "handlers": ["console"], "propagate": False},
|
2019-03-18 20:49:43 +03:00
|
|
|
"django.security.DisallowedHost": {
|
|
|
|
"level": "ERROR",
|
2019-03-20 13:04:44 +03:00
|
|
|
"handlers": ["console"],
|
|
|
|
"propagate": False,
|
2015-10-26 01:30:36 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2015-10-04 00:54:29 +03:00
|
|
|
|
2019-03-20 13:04:44 +03:00
|
|
|
# Sentry
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
SENTRY_DSN = env("SENTRY_DSN")
|
|
|
|
SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)
|
|
|
|
|
|
|
|
sentry_logging = LoggingIntegration(
|
|
|
|
level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
|
2019-05-22 09:46:20 +03:00
|
|
|
event_level=logging.ERROR, # Send errors as events
|
2019-03-20 13:04:44 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
{%- if cookiecutter.use_celery == 'y' %}
|
|
|
|
sentry_sdk.init(
|
|
|
|
dsn=SENTRY_DSN,
|
|
|
|
integrations=[sentry_logging, DjangoIntegration(), CeleryIntegration()],
|
|
|
|
)
|
|
|
|
{% else %}
|
|
|
|
sentry_sdk.init(dsn=SENTRY_DSN, integrations=[sentry_logging, DjangoIntegration()])
|
|
|
|
{% endif -%}
|
2018-05-21 21:57:52 +03:00
|
|
|
{% endif %}
|
2018-03-06 14:28:25 +03:00
|
|
|
# Your stuff...
|
2016-08-31 18:56:25 +03:00
|
|
|
# ------------------------------------------------------------------------------
|