2013-08-16 15:35:18 +04:00
|
|
|
"""
|
2018-03-06 14:28:25 +03:00
|
|
|
Base settings to build other settings files upon.
|
2013-08-16 15:35:18 +04:00
|
|
|
"""
|
2018-03-06 14:28:25 +03:00
|
|
|
|
2015-04-20 00:09:00 +03:00
|
|
|
import environ
|
|
|
|
|
2017-02-21 22:55:51 +03:00
|
|
|
ROOT_DIR = environ.Path(__file__) - 3 # ({{ cookiecutter.project_slug }}/config/settings/base.py - 3 = {{ cookiecutter.project_slug }}/)
|
2016-04-20 20:00:35 +03:00
|
|
|
APPS_DIR = ROOT_DIR.path('{{ cookiecutter.project_slug }}')
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2017-01-09 21:35:13 +03:00
|
|
|
env = environ.Env()
|
|
|
|
|
2017-02-16 00:15:16 +03:00
|
|
|
READ_DOT_ENV_FILE = env.bool('DJANGO_READ_DOT_ENV_FILE', default=False)
|
2017-01-09 21:35:13 +03:00
|
|
|
if READ_DOT_ENV_FILE:
|
2018-03-06 14:28:25 +03:00
|
|
|
# OS environment variables take precedence over variables from .env
|
|
|
|
env.read_env(str(ROOT_DIR.path('.env')))
|
|
|
|
|
|
|
|
# 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'
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# APPS
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2017-02-13 21:33:52 +03:00
|
|
|
DJANGO_APPS = [
|
2015-04-20 00:09:00 +03:00
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.sites',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
2018-03-06 14:28:25 +03:00
|
|
|
# 'django.contrib.humanize', # Handy template tags
|
2015-04-20 00:09:00 +03:00
|
|
|
'django.contrib.admin',
|
2017-02-13 21:33:52 +03:00
|
|
|
]
|
|
|
|
THIRD_PARTY_APPS = [
|
2018-03-06 14:28:25 +03:00
|
|
|
'crispy_forms',
|
|
|
|
'allauth',
|
|
|
|
'allauth.account',
|
|
|
|
'allauth.socialaccount',
|
2018-03-14 06:17:46 +03:00
|
|
|
'rest_framework',
|
2018-03-06 14:28:25 +03:00
|
|
|
]
|
2017-02-13 21:33:52 +03:00
|
|
|
LOCAL_APPS = [
|
2018-06-05 12:18:35 +03:00
|
|
|
'{{ cookiecutter.project_slug }}.users.apps.UsersAppConfig',
|
2015-04-20 00:09:00 +03:00
|
|
|
# Your stuff: custom apps go here
|
2017-02-13 21:33:52 +03:00
|
|
|
]
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
2015-04-20 00:09:00 +03:00
|
|
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# MIGRATIONS
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#migration-modules
|
2015-04-20 00:09:00 +03:00
|
|
|
MIGRATION_MODULES = {
|
2016-04-20 20:00:35 +03:00
|
|
|
'sites': '{{ cookiecutter.project_slug }}.contrib.sites.migrations'
|
2015-04-20 00:09:00 +03:00
|
|
|
}
|
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# AUTHENTICATION
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#authentication-backends
|
|
|
|
AUTHENTICATION_BACKENDS = [
|
|
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
|
|
'allauth.account.auth_backends.AuthenticationBackend',
|
|
|
|
]
|
|
|
|
# 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'
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# PASSWORDS
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#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.PBKDF2PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
|
|
|
]
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
|
|
{
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
|
|
},
|
|
|
|
]
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# MIDDLEWARE
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
|
|
|
|
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',
|
2017-02-13 21:33:52 +03:00
|
|
|
]
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# STATIC
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#static-root
|
|
|
|
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',
|
|
|
|
]
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# MEDIA
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# 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/'
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# TEMPLATES
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
2015-05-08 05:13:49 +03:00
|
|
|
TEMPLATES = [
|
|
|
|
{
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
|
2015-05-08 05:13:49 +03:00
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
|
2015-05-08 05:13:49 +03:00
|
|
|
'DIRS': [
|
|
|
|
str(APPS_DIR.path('templates')),
|
|
|
|
],
|
|
|
|
'OPTIONS': {
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
|
2015-05-08 05:13:49 +03:00
|
|
|
'debug': DEBUG,
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
|
2015-05-08 05:13:49 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
|
|
|
|
'loaders': [
|
|
|
|
'django.template.loaders.filesystem.Loader',
|
|
|
|
'django.template.loaders.app_directories.Loader',
|
|
|
|
],
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
|
2015-05-08 05:13:49 +03:00
|
|
|
'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',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
2018-03-06 14:28:25 +03:00
|
|
|
# http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
|
2016-08-16 22:22:16 +03:00
|
|
|
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# FIXTURES
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs
|
|
|
|
FIXTURE_DIRS = (
|
|
|
|
str(APPS_DIR.path('fixtures')),
|
|
|
|
)
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# EMAIL
|
2017-03-17 05:19:42 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
|
|
|
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
|
2016-09-15 06:37:57 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
# ADMIN
|
2016-09-15 06:37:57 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-05-14 10:09:24 +03:00
|
|
|
# Django Admin URL.
|
|
|
|
ADMIN_URL = 'admin/'
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
|
|
|
ADMINS = [
|
|
|
|
("""{{cookiecutter.author_name}}""", '{{cookiecutter.email}}'),
|
2016-09-15 06:37:57 +03:00
|
|
|
]
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
|
|
|
MANAGERS = ADMINS
|
2016-09-15 06:37:57 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
{% if cookiecutter.use_celery == 'y' -%}
|
|
|
|
# Celery
|
2015-04-20 00:09:00 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
2018-06-05 12:18:07 +03:00
|
|
|
INSTALLED_APPS += ['{{cookiecutter.project_slug}}.taskapp.celery.CeleryAppConfig']
|
2018-06-21 22:38:48 +03:00
|
|
|
if USE_TZ:
|
|
|
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-timezone
|
|
|
|
CELERY_TIMEZONE = TIME_ZONE
|
2018-03-06 14:28:25 +03:00
|
|
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-broker_url
|
2018-06-21 22:38:48 +03:00
|
|
|
CELERY_BROKER_URL = env('CELERY_BROKER_URL')
|
2018-03-06 14:28:25 +03:00
|
|
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend
|
2018-06-21 22:38:48 +03:00
|
|
|
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
2018-03-06 14:28:25 +03:00
|
|
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content
|
2018-03-01 14:25:33 +03:00
|
|
|
CELERY_ACCEPT_CONTENT = ['json']
|
2018-03-06 14:28:25 +03:00
|
|
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer
|
2018-03-01 14:25:33 +03:00
|
|
|
CELERY_TASK_SERIALIZER = 'json'
|
2018-03-06 14:28:25 +03:00
|
|
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_serializer
|
2018-03-01 14:25:33 +03:00
|
|
|
CELERY_RESULT_SERIALIZER = 'json'
|
2018-06-21 22:38:48 +03:00
|
|
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-time-limit
|
|
|
|
# TODO: set to whatever value is adequate in your circumstances
|
|
|
|
CELERYD_TASK_TIME_LIMIT = 5 * 60
|
|
|
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-soft-time-limit
|
|
|
|
# TODO: set to whatever value is adequate in your circumstances
|
|
|
|
CELERYD_TASK_SOFT_TIME_LIMIT = 60
|
2015-10-04 00:54:29 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
{%- 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' -%}
|
2016-06-18 05:07:45 +03:00
|
|
|
# django-compressor
|
|
|
|
# ------------------------------------------------------------------------------
|
2018-03-06 14:28:25 +03:00
|
|
|
# https://django-compressor.readthedocs.io/en/latest/quickstart/#installation
|
2017-02-13 21:33:52 +03:00
|
|
|
INSTALLED_APPS += ['compressor']
|
|
|
|
STATICFILES_FINDERS += ['compressor.finders.CompressorFinder']
|
2016-06-18 05:07:45 +03:00
|
|
|
|
2018-03-06 14:28:25 +03:00
|
|
|
{%- endif %}
|
|
|
|
# Your stuff...
|
2016-08-31 18:56:25 +03:00
|
|
|
# ------------------------------------------------------------------------------
|