· 7 years ago · Feb 09, 2018, 11:04 AM
1"""
2Django settings for shmot project.
3
4Generated by 'django-admin startproject' using Django 2.0.1.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/2.0/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.0/ref/settings/
11"""
12
13import os
14
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
18
19# Quick-start development settings - unsuitable for production
20# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
21
22# SECURITY WARNING: keep the secret key used in production secret!
23SECRET_KEY = 't+0+*wo*!t_)dz@7_8jxep4$o7ef39mjrq%9v&0&=jya^g*w1e'
24
25# SECURITY WARNING: don't run with debug turned on in production!
26DEBUG = True
27
28ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'shmot.pythonanywhere.com']
29
30# Application definition
31
32INSTALLED_APPS = [
33 'userapp',
34 'mainapp.apps.MainappConfig',
35 'django.contrib.admin',
36 'django.contrib.auth',
37 'django.contrib.contenttypes',
38 'django.contrib.sessions',
39 'django.contrib.messages',
40 'django.contrib.staticfiles',
41]
42
43MIDDLEWARE = [
44 'django.middleware.cache.UpdateCacheMiddleware', # must be first
45 'django.middleware.security.SecurityMiddleware',
46 'django.contrib.sessions.middleware.SessionMiddleware',
47 'django.middleware.common.CommonMiddleware',
48 'django.middleware.csrf.CsrfViewMiddleware',
49 'django.contrib.auth.middleware.AuthenticationMiddleware',
50 'django.contrib.messages.middleware.MessageMiddleware',
51 'django.middleware.clickjacking.XFrameOptionsMiddleware',
52 'django.middleware.cache.FetchFromCacheMiddleware', # must be last
53]
54
55ROOT_URLCONF = 'shmot.urls'
56
57TEMPLATES = [
58 {
59 'BACKEND': 'django.template.backends.django.DjangoTemplates',
60 'DIRS': [],
61 'APP_DIRS': True,
62 'OPTIONS': {
63 'context_processors': [
64 'django.template.context_processors.debug',
65 'django.template.context_processors.request',
66 'django.contrib.auth.context_processors.auth',
67 'django.contrib.messages.context_processors.messages',
68 ],
69 },
70 },
71]
72
73WSGI_APPLICATION = 'shmot.wsgi.application'
74
75
76# Database
77# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
78
79DATABASES = {
80 'default': {
81 'ENGINE': 'django.db.backends.postgresql_psycopg2',
82 'NAME': 'shmotdb', # Database name (Database -> schemas)
83 'USER': 'shmotuser', # Name of db user (must set while creating db)
84 'PASSWORD': '0001234', # User's password
85 'HOST': 'localhost',
86 'PORT': '',
87 }
88}
89
90
91# Password validation
92# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
93
94AUTH_PASSWORD_VALIDATORS = [
95 {
96 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
97 },
98 {
99 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
100 },
101 {
102 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
103 },
104 {
105 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
106 },
107]
108
109
110# Internationalization
111# https://docs.djangoproject.com/en/2.0/topics/i18n/
112
113LANGUAGE_CODE = 'ru-ru'
114
115TIME_ZONE = 'Europe/Moscow'
116
117USE_I18N = True
118
119USE_L10N = True
120
121USE_TZ = False
122
123
124# Static files (CSS, JavaScript, Images)
125# https://docs.djangoproject.com/en/2.0/howto/static-files/
126
127STATIC_URL = '/static/'
128#STATIC_ROOT = os.path.join(BASE_DIR, 'static')
129STATICFILES_DIRS = [
130 os.path.join(BASE_DIR, 'static'),
131]
132
133# Caches
134
135CACHES = { # apt install memcached
136 'default': {
137 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
138 'LOCATION': 'unix:/tmp/memcached.sock',
139 }
140}
141
142CACHE_MIDDLEWARE_ALIAS = 'default' # Cache alias (see CACHES)
143CACHE_MIDDLEWARE_SECONDS = 604800 # Timeout in s (604800s = 1 week)
144CACHE_MIDDLEWARE_KEY_PREFIX = '' # -
145
146# Session
147
148SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
149
150# Login/Logout
151
152LOGIN_REDIRECT_URL = 'home'
153LOGOUT_REDIRECT_URL = 'home'
154
155# Email backend
156
157EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
158EMAIL_FILE_PATH = os.path.join(BASE_DIR, "sent_emails")
159
160# User model (custom)
161
162AUTH_USER_MODEL = 'userapp.CustomUser'
163
164# Append slash (default=true)
165
166APPEND_SLASH = True