· 5 years ago · Aug 17, 2020, 01:06 PM
1"""
2Django settings for duelproject project.
3
4Generated by 'django-admin startproject' using Django 3.1.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/3.1/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/3.1/ref/settings/
11"""
12
13from pathlib import Path
14import os
15import sys
16
17# Build paths inside the project like this: BASE_DIR / 'subdir'.
18BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
19
20INTERNAL_IPS = [
21 '127.0.0.1',
22]
23
24# Quick-start development settings - unsuitable for production
25# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
26
27# SECURITY WARNING: keep the secret key used in production secret!
28SECRET_KEY = 'dk)ms&i0o98e@12hpzk9*h2#yb15rx6an_@uc!$w1hz6!nx^2s'
29
30DEBUG = True
31
32ALLOWED_HOSTS = []
33
34# Application definition
35
36INSTALLED_APPS = [
37 'django.contrib.admin',
38 'django.contrib.auth',
39 'django.contrib.contenttypes',
40 'django.contrib.sessions',
41 'django.contrib.messages',
42 'django.contrib.staticfiles',
43 'debug_toolbar',
44 'django.contrib.sites',
45 'allauth',
46 'allauth.account',
47 'allauth.socialaccount',
48 'dj_rest_auth.registration',
49 'users.apps.UsersConfig', # App users
50 'rest_framework',
51 'rest_framework.authtoken', # Token
52 'rest_framework_swagger',
53 'django_extensions',
54 'drf_yasg', # swager
55 'dj_rest_auth',
56
57]
58
59SITE_ID = 1
60
61
62REST_FRAMEWORK = {
63 # Use Django's standard `django.contrib.auth` permissions,
64 # or allow read-only access for unauthenticated users.
65 'DEFAULT_PERMISSION_CLASSES': [
66 # 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
67 'rest_framework.authentication.TokenAuthentication',
68 # 'rest_framework.permissions.IsAuthenticated',
69 ],
70 'DEFAULT_AUTHENTICATION_CLASSES':[
71 'dj_rest_auth.jwt_auth.JWTCookieAuthentication',
72 # 'rest_framework.authentication.TokenAuthentication',
73
74 # 'rest_framework.authentication.BasicAuthentication',
75 # 'rest_framework.authentication.SessionAuthentication',
76
77 ]
78}
79
80REST_USE_JWT = True
81JWT_AUTH_COOKIE = 'jwt-auth'
82
83
84AUTH_USER_MODEL = 'users.User'
85
86MIDDLEWARE = [
87 'django.middleware.security.SecurityMiddleware',
88 'django.contrib.sessions.middleware.SessionMiddleware',
89 'django.middleware.common.CommonMiddleware',
90 'django.middleware.csrf.CsrfViewMiddleware',
91 'debug_toolbar.middleware.DebugToolbarMiddleware',
92
93 'django.contrib.auth.middleware.AuthenticationMiddleware',
94 'django.contrib.messages.middleware.MessageMiddleware',
95 'django.middleware.clickjacking.XFrameOptionsMiddleware',
96]
97
98ROOT_URLCONF = 'duelproject.urls'
99
100TEMPLATES = [
101 {
102 'BACKEND': 'django.template.backends.django.DjangoTemplates',
103 'DIRS': [os.path.join(BASE_DIR, 'templates')]
104 ,
105 'APP_DIRS': True,
106 'OPTIONS': {
107 'context_processors': [
108 'django.template.context_processors.debug',
109 'django.template.context_processors.request',
110 'django.contrib.auth.context_processors.auth',
111 'django.contrib.messages.context_processors.messages',
112 ],
113 },
114 },
115]
116
117WSGI_APPLICATION = 'duelproject.wsgi.application'
118
119# Database
120# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
121
122
123DATABASES = {
124 'default': {
125 'ENGINE': 'django.db.backends.postgresql_psycopg2',
126
127 # 'ENGINE': 'django.db.backends.postgresql',
128 'NAME': 'duelproject',
129 'USER': 'postgres',
130 'PASSWORD': 'admin',
131 'HOST': '127.0.0.1',
132 'PORT': '5432',
133 }
134}
135
136
137
138# REST_USE_JWT = True
139# JWT_AUTH_COOKIE = 'jwt-auth'
140DEBUG_TOOLBAR_PANELS = [
141 # 'debug_toolbar.panels.versions.VersionsPanel',
142 'debug_toolbar.panels.timer.TimerPanel',
143 # 'debug_toolbar.panels.settings.SettingsPanel',
144 'debug_toolbar.panels.headers.HeadersPanel',
145
146 'debug_toolbar.panels.request.RequestPanel',
147 'debug_toolbar.panels.sql.SQLPanel',
148 # 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
149 'debug_toolbar.panels.templates.TemplatesPanel',
150 'debug_toolbar.panels.cache.CachePanel',
151 # 'debug_toolbar.panels.signals.SignalsPanel',
152 # 'debug_toolbar.panels.signals.SignalDebugPanel',
153 # 'debug_toolbar.panels.logging.LoggingPanel',
154 # 'debug_toolbar.panels.redirects.RedirectsPanel',
155 # 'debug_toolbar.panels.profiling.ProfilingPanel',
156]
157
158# Password validation
159# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
160
161AUTH_PASSWORD_VALIDATORS = [
162 {
163 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
164 },
165 {
166 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
167 },
168 {
169 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
170 },
171 {
172 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
173 },
174]
175
176# Internationalization
177# https://docs.djangoproject.com/en/3.0/topics/i18n/
178
179
180LANGUAGE_CODE = 'en-us'
181
182TIME_ZONE = 'Europe/Kiev'
183
184USE_I18N = True
185
186USE_L10N = True
187
188USE_TZ = True
189EMAIL_BACKEND = "sendgrid_backend.SendgridBackend"
190SENDGRID_API_KEY = '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'
191# SENDGRID_API_KEY = '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'
192
193ACCOUNT_USERNAME_REQUIRED = False
194ACCOUNT_EMAIL_REQUIRED = True
195ACCOUNT_AUTHENTICATION_METHOD = 'email'
196ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
197ACCOUNT_CONFIRM_EMAIL_ON_GET = False
198
199
200# Static files (CSS, JavaScript, Images)
201# https://docs.djangoproject.com/en/3.0/howto/static-files/
202
203STATIC_URL = '/static/'
204STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
205STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
206