· 4 years ago · Nov 14, 2020, 02:24 AM
1"""
2Django settings for project project.
3
4Generated by 'django-admin startproject' using Django 2.2.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/2.2/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.2/ref/settings/
11"""
12
13import os
14
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16import django_heroku
17
18BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
19
20
21# Quick-start development settings - unsuitable for production
22# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
23
24# SECURITY WARNING: keep the secret key used in production secret!
25SECRET_KEY = os.environ.get("SECRET_KEY", "xxwa$bi9ns@m3uk02_ga!==0cy*paygw3o(3&aep)v2o$hcgx6")
26
27# SECURITY WARNING: don't run with debug turned on in production!
28DEBUG = True
29
30ALLOWED_HOSTS = []
31
32
33# Application definition
34
35INSTALLED_APPS = [
36
37 'rest_framework',
38 'rest_framework.authtoken',
39 'rest_auth',
40 'django.contrib.sites',
41 'allauth',
42 'allauth.account',
43 'allauth.socialaccount',
44 'rest_auth.registration',
45
46 'django.contrib.admin',
47 'django.contrib.auth',
48 'django.contrib.contenttypes',
49 'django.contrib.sessions',
50 'django.contrib.messages',
51 'whitenoise.runserver_nostatic',
52 'django.contrib.staticfiles',
53
54 'storages',
55 'corsheaders',
56
57 'core',
58 'mis',
59]
60
61SITE_ID = 1
62
63MIDDLEWARE = [
64 'django.middleware.security.SecurityMiddleware',
65 'whitenoise.middleware.WhiteNoiseMiddleware', # add whitenoise
66 'django.contrib.sessions.middleware.SessionMiddleware',
67 'corsheaders.middleware.CorsMiddleware',
68 'django.middleware.common.CommonMiddleware',
69 'django.middleware.csrf.CsrfViewMiddleware',
70 'django.contrib.auth.middleware.AuthenticationMiddleware',
71 'django.contrib.messages.middleware.MessageMiddleware',
72 'django.middleware.clickjacking.XFrameOptionsMiddleware',
73]
74
75ROOT_URLCONF = 'project.urls'
76
77TEMPLATES = [
78 {
79 'BACKEND': 'django.template.backends.django.DjangoTemplates',
80 'DIRS': [],
81 'APP_DIRS': True,
82 'OPTIONS': {
83 'context_processors': [
84 'django.template.context_processors.debug',
85 'django.template.context_processors.request',
86 'django.contrib.auth.context_processors.auth',
87 'django.contrib.messages.context_processors.messages',
88 ],
89 },
90 },
91]
92
93WSGI_APPLICATION = 'project.wsgi.application'
94
95
96# Database
97# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
98
99DATABASES = {
100 'default': {
101 'ENGINE': 'django.db.backends.sqlite3',
102 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
103 }
104}
105
106
107# Password validation
108# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
109AUTH_PASSWORD_VALIDATORS = [
110 {
111 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
112 },
113 {
114 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
115 },
116 {
117 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
118 },
119 {
120 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
121 },
122]
123AUTHENTICATION_BACKENDS = (
124 'django.contrib.auth.backends.RemoteUserBackend',
125 'django.contrib.auth.backends.ModelBackend',
126)
127
128
129# Internationalization
130# https://docs.djangoproject.com/en/2.2/topics/i18n/
131
132LANGUAGE_CODE = 'en-us'
133
134TIME_ZONE = 'UTC'
135
136USE_I18N = True
137
138USE_L10N = True
139
140USE_TZ = True
141
142
143REST_FRAMEWORK = {
144 'DEFAULT_AUTHENTICATION_CLASSES': (
145 'rest_framework.authentication.TokenAuthentication',
146 'rest_framework.authentication.SessionAuthentication',
147 ),
148 'DEFAULT_PERMISSION_CLASSES': (
149 'rest_framework.permissions.IsAdminUser'
150 ),
151}
152
153
154
155
156
157# Static files (CSS, JavaScript, Images)
158# https://docs.djangoproject.com/en/2.2/howto/static-files/
159STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
160
161STATIC_URL = '/static/'
162PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
163STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
164STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
165STATICFILES_ROOT = os.path.join(BASE_DIR, 'staticfiles')
166MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
167MEDIA_ROOT2 = os.path.join(BASE_DIR, '')
168MEDIA_URL = '/media/'
169
170CORS_ALLOW_ALL_ORIGINS = True
171CORS_ORIGIN_ALLOW = True
172CORS_ORIGIN_ALLOW_ALL = True
173CORS_ALLOW_METHODS = [
174 'DELETE',
175 'GET',
176 'OPTIONS',
177 'PATCH',
178 'POST',
179 'PUT',
180]
181CORS_ALLOWED_ORIGINS = [
182 "http://localhost:3000",
183 "http://127.0.0.1:3000",
184]
185
186CORS_ALLOW_HEADERS = [
187 'accept',
188 'accept-encoding',
189 'authorization',
190 'content-type',
191 'dnt',
192 'origin',
193 'user-agent',
194 'x-csrftoken',
195 'x-requested-with',
196]
197
198ADMINS = (
199 ('Admin', 'sanyam1992000@gmail.com'),
200 ('Sanyam', 'sanyam30dav@gmail.com'),
201)
202MANAGERS = ADMINS
203
204CACHE_TTL = 60 * 60 * 2
205# CACHE_TTL = getattr(settings, 'CACHE_TTL', DEFAULT_TIMEOUT)
206CACHES = {
207 "default": {
208 "BACKEND": "django_redis.cache.RedisCache",
209 "LOCATION": os.environ.get("REDIS_URL", "redis://127.0.0.1:6379"),
210 "OPTIONS": {
211 "CLIENT_CLASS": "django_redis.client.DefaultClient"
212 },
213 "KEY_PREFIX": "example"
214 }
215}
216
217CELERY_ACCEPT_CONTENT = ['json']
218CELERY_TASK_SERIALIZER = 'json'
219BROKER_URL = os.environ.get("REDIS_URL", "redis://127.0.0.1:6379")
220CELERY_BROKER_URL = os.environ.get("REDIS_URL", "redis://127.0.0.1:6379")
221CELERY_RESULT_BACKEND = os.environ.get("REDIS_URL", "redis://127.0.0.1:6379")
222
223AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID")
224AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY")
225AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME", 'cncymca')
226AWS_S3_FILE_OVERWRITE = False
227AWS_DEFAULT_ACL = None
228DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
229AWS_S3_REGION_NAME = 'us-east-2'
230AWS_S3_SIGNATURE_VERSION = 's3v4'
231AWS_S3_HOST = 's3.us-east-2.amazonaws.com'
232
233
234django_heroku.settings(locals())
235