Created
May 3, 2017 13:39
-
-
Save OndrejIT/63a5523bb323983302e525499ac811f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import yaml | |
from lib import LazyDict | |
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | |
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
# Load config file | |
CONFIGFILE = os.environ.get("CONFIGFILE", "/opt/free1/etc/free1.prod.conf") | |
CONFIG = LazyDict(yaml.load(open(CONFIGFILE, "r"))) | |
# Quick-start development settings - unsuitable for production | |
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ | |
# SECURITY WARNING: keep the secret key used in production secret! | |
SECRET_KEY = CONFIG.secret | |
# SECURITY WARNING: don"t run with debug turned on in production! | |
DEBUG = CONFIG.debug | |
ALLOWED_HOSTS = ["*"] | |
# Application definition | |
INSTALLED_APPS = [ | |
"django.contrib.admin", | |
"django.contrib.auth", | |
"django.contrib.contenttypes", | |
"django.contrib.sessions", | |
"django.contrib.messages", | |
"django.contrib.staticfiles", | |
"rest_framework", | |
"modules.content", | |
] | |
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", | |
] | |
ROOT_URLCONF = "urls" | |
TEMPLATES = [ | |
{ | |
"BACKEND": "django.template.backends.jinja2.Jinja2", | |
"DIRS": [os.path.join(BASE_DIR, "resources/templates/")], | |
"APP_DIRS": True, | |
"OPTIONS": { | |
"environment": "modules.content.jinja.environment", | |
} | |
}, | |
{ | |
"BACKEND": "django.template.backends.django.DjangoTemplates", | |
"DIRS": [], | |
"APP_DIRS": True, | |
"OPTIONS": { | |
"context_processors": [ | |
"django.template.context_processors.debug", | |
"django.template.context_processors.request", | |
"django.contrib.auth.context_processors.auth", | |
"django.contrib.messages.context_processors.messages", | |
], | |
}, | |
}, | |
] | |
REST_FRAMEWORK = { | |
"PAGE_SIZE": 50, | |
"DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.NamespaceVersioning", | |
"DEFAULT_AUTHENTICATION_CLASSES": [ | |
"rest_framework.authentication.SessionAuthentication", | |
"rest_framework.authentication.BasicAuthentication", | |
], | |
"DEFAULT_PERMISSION_CLASSES": [ | |
"rest_framework.permissions.IsAdminUser", | |
], | |
} | |
WSGI_APPLICATION = "wsgi.application" | |
# Database | |
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases | |
DATABASES = { | |
"default": { | |
"ENGINE": "django.db.backends.postgresql", | |
"NAME": CONFIG.db.name, | |
"USER": CONFIG.db.user, | |
"PASSWORD": CONFIG.db.passwd, | |
"HOST": CONFIG.db.host, | |
"PORT": CONFIG.db.port, | |
} | |
} | |
# Celery | |
# http://celery.readthedocs.org/en/latest/getting-started/brokers/redis.html | |
CELERY = { | |
"BROKER_URL": CONFIG.celery_broker, | |
"BROKER_TRANSPORT_OPTIONS": { | |
"fanout_prefix": True, | |
"fanout_patterns": True, | |
"visibility_timeout": 86400, | |
}, | |
"CELERY_RESULT_BACKEND": CONFIG.celery_result_backend, | |
"TIMEZONE": "Europe/Prague", | |
"TASK_RESULT_EXPIRES": 3600, | |
"TRACK_STARTED": True, | |
} | |
# Password validation | |
# https://docs.djangoproject.com/en/1.10/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", | |
}, | |
] | |
STATIC_URL = "/static/" | |
STATIC_ROOT = os.path.join(BASE_DIR, "resources/static/") | |
# Internationalization | |
# https://docs.djangoproject.com/en/1.10/topics/i18n/ | |
LANGUAGE_CODE = "cz" | |
TIME_ZONE = "Europe/Prague" | |
USE_I18N = True | |
USE_L10N = True | |
USE_TZ = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment