telegram_bots/config/settings.py

137 lines
3.8 KiB
Python
Raw Normal View History

2019-01-11 19:16:01 +00:00
import os
import environ
2019-01-25 16:33:22 +00:00
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
2019-01-11 19:16:01 +00:00
BASE_DIR = environ.Path(__file__) - 2
env = environ.Env()
env_file = str(BASE_DIR.path('.env'))
if os.path.exists(env_file):
env.read_env(env_file)
SECRET_KEY = '6)mck*tk2eq++!01pr2!7qo7#zf_e(hi_m=-qa4x-ah)lvvt4-'
2019-01-11 20:20:50 +00:00
DEBUG = env.bool('DJANGO_DEBUG', True)
2019-03-08 10:48:18 +00:00
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', [])
2022-04-12 12:22:30 +00:00
CSRF_TRUSTED_ORIGINS = ['bots.bakatrouble.me']
2019-01-11 19:16:01 +00:00
INSTALLED_APPS = [
2019-01-26 07:17:46 +00:00
'django_extensions',
'bootstrap4',
2019-03-09 19:11:42 +00:00
'crispy_forms',
2019-01-26 07:17:46 +00:00
'djconfig',
2019-11-27 18:21:24 +00:00
'jsoneditor',
2019-01-26 07:17:46 +00:00
2019-01-11 19:16:01 +00:00
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
2019-01-19 06:52:00 +00:00
'cabinet.apps.CabinetConfig',
'feeds.apps.FeedsConfig',
2019-01-27 21:20:09 +00:00
'aggregator.apps.AggregatorConfig',
2019-11-12 17:13:56 +00:00
'bots.apps.BotsConfig',
2019-01-11 19:16:01 +00:00
]
MIDDLEWARE = [
2019-01-23 14:25:56 +00:00
'djconfig.middleware.DjConfigMiddleware',
2019-01-11 19:16:01 +00:00
'django.middleware.security.SecurityMiddleware',
2021-03-11 22:28:31 +00:00
'whitenoise.middleware.WhiteNoiseMiddleware',
2019-01-11 19:16:01 +00:00
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
2022-04-09 21:55:23 +00:00
# 'django.middleware.csrf.CsrfViewMiddleware',
2019-01-11 19:16:01 +00:00
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'config.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [str(BASE_DIR.path('templates'))],
'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',
2019-01-19 06:52:00 +00:00
'djconfig.context_processors.config',
2019-01-11 19:16:01 +00:00
'config.utils.turbolinks',
2019-01-19 06:52:00 +00:00
'cabinet.utils.cabinet_context_processor',
2019-01-11 19:16:01 +00:00
],
},
},
]
WSGI_APPLICATION = 'config.wsgi.application'
2021-04-23 21:31:12 +00:00
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
2019-01-11 19:16:01 +00:00
DATABASES = {
'default': env.db('DATABASE_URL', default='sqlite:///db.sqlite3'),
}
DATABASES['default']['ATOMIC_REQUESTS'] = True
LANGUAGE_CODE = 'en-us'
2019-01-26 09:36:44 +00:00
TIME_ZONE = 'Europe/Moscow'
2019-01-11 19:16:01 +00:00
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATICFILES_DIRS = [
str(BASE_DIR.path('static')),
]
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
2019-01-19 06:52:00 +00:00
CACHES = {
"default": {
2019-11-25 19:37:01 +00:00
"BACKEND": "redis_cache.RedisCache",
"LOCATION": ["127.0.0.1:6379"],
2019-01-19 06:52:00 +00:00
"OPTIONS": {
2019-11-25 19:37:01 +00:00
'DB': 4,
'PARSER_CLASS': 'redis.connection.HiredisParser',
'CONNECTION_POOL_CLASS': 'redis.BlockingConnectionPool',
'CONNECTION_POOL_CLASS_KWARGS': {
'max_connections': 50,
'timeout': 20,
},
'MAX_CONNECTIONS': 1000,
'PICKLE_VERSION': -1,
2019-01-19 06:52:00 +00:00
}
}
}
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"
2019-01-11 19:16:01 +00:00
PUBLIC_ROOT = BASE_DIR.path('public')
STATIC_URL = '/static/'
STATIC_ROOT = str(PUBLIC_ROOT.path('static'))
MEDIA_URL = '/uploads/'
MEDIA_ROOT = str(PUBLIC_ROOT.path('uploads'))
2022-04-10 09:04:41 +00:00
DATA_UPLOAD_MAX_MEMORY_SIZE = 20 * 1024 * 1024
2019-01-11 19:16:01 +00:00
LOGIN_URL = 'cabinet:login'
LOGIN_REDIRECT_URL = 'cabinet:index'
LOGOUT_REDIRECT_URL = LOGIN_URL
2019-01-19 02:58:03 +00:00
2019-03-09 19:11:42 +00:00
CRISPY_TEMPLATE_PACK = 'bootstrap4'
2019-11-27 18:21:24 +00:00
JSON_EDITOR_JS = 'https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/7.0.4/jsoneditor.min.js'
JSON_EDITOR_CSS = 'https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/7.0.4/jsoneditor.min.css'
2019-01-25 16:33:22 +00:00
sentry_sdk.init(
dsn=env.str('SENTRY_DSN', None),
integrations=[DjangoIntegration()],
)