2013-08-16 15:35:18 +04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Django settings for {{cookiecutter.project_name}} project.
|
|
|
|
|
|
|
|
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/
|
|
|
|
"""
|
2015-04-20 00:09:00 +03:00
|
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
|
|
|
|
import environ
|
|
|
|
|
2016-05-18 02:15:53 +03:00
|
|
|
ROOT_DIR = environ.Path(__file__) - 3 # ({{ cookiecutter.project_slug }}/config/settings/common.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
|
|
|
|
|
|
|
env = environ.Env()
|
|
|
|
|
|
|
|
# APP CONFIGURATION
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
DJANGO_APPS = (
|
|
|
|
# Default Django apps:
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.sites',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
|
|
|
|
# Useful template tags:
|
|
|
|
# 'django.contrib.humanize',
|
|
|
|
|
|
|
|
# Admin
|
|
|
|
'django.contrib.admin',
|
|
|
|
)
|
|
|
|
THIRD_PARTY_APPS = (
|
|
|
|
'crispy_forms', # Form layouts
|
|
|
|
'allauth', # registration
|
|
|
|
'allauth.account', # registration
|
|
|
|
'allauth.socialaccount', # registration
|
|
|
|
)
|
|
|
|
|
|
|
|
# Apps specific for this project go here.
|
|
|
|
LOCAL_APPS = (
|
2016-06-18 23:18:40 +03:00
|
|
|
# custom users app
|
|
|
|
'{{ cookiecutter.project_slug }}.users.apps.UsersConfig',
|
2015-04-20 00:09:00 +03:00
|
|
|
# Your stuff: custom apps go here
|
|
|
|
)
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
|
|
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
|
|
|
|
|
|
|
# MIDDLEWARE CONFIGURATION
|
|
|
|
# ------------------------------------------------------------------------------
|
2016-09-15 06:28:33 +03:00
|
|
|
MIDDLEWARE = (
|
2016-06-04 02:07:27 +03:00
|
|
|
'django.middleware.security.SecurityMiddleware',
|
2015-04-20 00:09:00 +03:00
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
|
)
|
|
|
|
|
|
|
|
# MIGRATIONS CONFIGURATION
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
MIGRATION_MODULES = {
|
2016-04-20 20:00:35 +03:00
|
|
|
'sites': '{{ cookiecutter.project_slug }}.contrib.sites.migrations'
|
2015-04-20 00:09:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# DEBUG
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
2016-04-13 00:23:00 +03:00
|
|
|
DEBUG = env.bool('DJANGO_DEBUG', False)
|
2015-04-20 00:09:00 +03:00
|
|
|
|
|
|
|
# FIXTURE CONFIGURATION
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
|
|
|
|
FIXTURE_DIRS = (
|
|
|
|
str(APPS_DIR.path('fixtures')),
|
|
|
|
)
|
|
|
|
|
|
|
|
# EMAIL CONFIGURATION
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
|
|
|
|
|
|
|
|
# MANAGER CONFIGURATION
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
|
|
|
ADMINS = (
|
|
|
|
("""{{cookiecutter.author_name}}""", '{{cookiecutter.email}}'),
|
|
|
|
)
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
|
|
|
MANAGERS = ADMINS
|
|
|
|
|
|
|
|
# DATABASE CONFIGURATION
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
|
|
|
DATABASES = {
|
2016-04-20 20:00:35 +03:00
|
|
|
'default': env.db('DATABASE_URL', default='postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}'),
|
2015-04-20 00:09:00 +03:00
|
|
|
}
|
|
|
|
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
|
|
|
|
# ------------------------------------------------------------------------------
|
2015-05-08 05:13:49 +03:00
|
|
|
# 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
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2016-05-09 23:18:58 +03:00
|
|
|
# See: 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
|
|
|
|
|
|
|
# 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
|
|
|
|
# ------------------------------------------------------------------------------
|
2015-04-24 15:12:34 +03:00
|
|
|
ROOT_URLCONF = 'config.urls'
|
2015-04-20 00:09:00 +03:00
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
|
2015-04-24 15:12:34 +03:00
|
|
|
WSGI_APPLICATION = 'config.wsgi.application'
|
2015-04-20 00:09:00 +03:00
|
|
|
|
2016-09-15 06:37:57 +03:00
|
|
|
|
|
|
|
# PASSWORD VALIDATION
|
|
|
|
# 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
|
|
|
# AUTHENTICATION CONFIGURATION
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
AUTHENTICATION_BACKENDS = (
|
|
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
|
|
'allauth.account.auth_backends.AuthenticationBackend',
|
|
|
|
)
|
|
|
|
|
|
|
|
# Some really nice defaults
|
|
|
|
ACCOUNT_AUTHENTICATION_METHOD = 'username'
|
|
|
|
ACCOUNT_EMAIL_REQUIRED = True
|
|
|
|
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
2016-02-18 23:44:08 +03:00
|
|
|
|
2016-04-13 00:23:00 +03:00
|
|
|
ACCOUNT_ALLOW_REGISTRATION = env.bool('DJANGO_ACCOUNT_ALLOW_REGISTRATION', True)
|
2016-04-20 20:00:35 +03:00
|
|
|
ACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.AccountAdapter'
|
|
|
|
SOCIALACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.SocialAccountAdapter'
|
2015-04-20 00:09:00 +03:00
|
|
|
|
|
|
|
# Custom user app defaults
|
|
|
|
# Select the correct user model
|
|
|
|
AUTH_USER_MODEL = 'users.User'
|
|
|
|
LOGIN_REDIRECT_URL = 'users:redirect'
|
|
|
|
LOGIN_URL = 'account_login'
|
|
|
|
|
|
|
|
# SLUGLIFIER
|
|
|
|
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
|
2016-04-13 00:23:00 +03:00
|
|
|
{% if cookiecutter.use_celery == 'y' %}
|
2014-10-12 12:32:17 +04:00
|
|
|
########## CELERY
|
2016-04-20 20:00:35 +03:00
|
|
|
INSTALLED_APPS += ('{{cookiecutter.project_slug}}.taskapp.celery.CeleryConfig',)
|
2014-10-12 12:32:17 +04:00
|
|
|
# if you are not using the django database broker (e.g. rabbitmq, redis, memcached), you can remove the next line.
|
|
|
|
INSTALLED_APPS += ('kombu.transport.django',)
|
2016-04-13 00:23:00 +03:00
|
|
|
BROKER_URL = env('CELERY_BROKER_URL', default='django://')
|
2016-07-14 22:06:29 +03:00
|
|
|
if BROKER_URL == 'django://':
|
|
|
|
CELERY_RESULT_BACKEND = 'redis://'
|
|
|
|
else:
|
|
|
|
CELERY_RESULT_BACKEND = BROKER_URL
|
2014-10-12 12:32:17 +04:00
|
|
|
########## END CELERY
|
|
|
|
{% endif %}
|
2015-10-04 00:54:29 +03:00
|
|
|
|
2016-08-31 18:52:11 +03:00
|
|
|
{%- if cookiecutter.use_compressor == 'y'-%}
|
2016-06-18 05:07:45 +03:00
|
|
|
# django-compressor
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
INSTALLED_APPS += ("compressor", )
|
|
|
|
STATICFILES_FINDERS += ("compressor.finders.CompressorFinder", )
|
|
|
|
{%- endif %}
|
|
|
|
|
2015-10-04 01:42:33 +03:00
|
|
|
# Location of root django.contrib.admin URL, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
2015-10-04 00:54:29 +03:00
|
|
|
ADMIN_URL = r'^admin/'
|
|
|
|
|
2015-04-20 00:09:00 +03:00
|
|
|
# Your common stuff: Below this line define 3rd party library settings
|
2016-08-31 18:56:25 +03:00
|
|
|
# ------------------------------------------------------------------------------
|