· 4 years ago · Jul 11, 2021, 10:36 AM
1"""
2Django settings for sportpro project.
3
4Generated by 'django-admin startproject' using Django 2.2.18.
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# from corsheaders.defaults import default_methods
13from django.conf import settings
14from firebase_admin import credentials
15import firebase_admin
16import os
17import environ
18# Initialise environment variables
19import django_heroku
20
21# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
22BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
23env = environ.Env()
24environ.Env.read_env()
25
26
27# Quick-start development settings - unsuitable for production
28# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
29
30# SECURITY WARNING: keep the secret key used in production secret!
31SECRET_KEY = env('SECRET_KEY')
32
33# SECURITY WARNING: don't run with debug turned on in production!
34DEBUG = env('DEBUG')
35
36ALLOWED_HOSTS = ['*']
37
38
39# Application definition
40
41INSTALLED_APPS = [
42 'jet',
43 'django.contrib.admin',
44 'django.contrib.auth',
45 'django.contrib.contenttypes',
46 'django.contrib.sessions',
47 'django.contrib.messages',
48 'django.contrib.staticfiles',
49 'rest_framework',
50 'user',
51 'sportpro_app',
52 'jwt',
53 'tabular_permissions',
54 'rest_framework.authtoken',
55 'corsheaders',
56 'django_filters',
57 'django_extensions',
58]
59
60MIDDLEWARE = [
61 'django.middleware.security.SecurityMiddleware',
62 'django.contrib.sessions.middleware.SessionMiddleware',
63 'corsheaders.middleware.CorsMiddleware',
64 'django.middleware.common.CommonMiddleware',
65 'django.middleware.csrf.CsrfViewMiddleware',
66 'django.contrib.auth.middleware.AuthenticationMiddleware',
67 'django.contrib.messages.middleware.MessageMiddleware',
68 'django.middleware.clickjacking.XFrameOptionsMiddleware',
69]
70
71CORS_ORIGIN_ALLOW_ALL = True
72
73
74ROOT_URLCONF = 'sportpro.urls'
75
76STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
77
78TEMPLATES = [
79 {
80 'BACKEND': 'django.template.backends.django.DjangoTemplates',
81 'DIRS': [os.path.join(BASE_DIR, "templates")],
82 'APP_DIRS': True,
83 'OPTIONS': {
84 'context_processors': [
85 'django.template.context_processors.debug',
86 'django.template.context_processors.request',
87 'django.contrib.auth.context_processors.auth',
88 'django.contrib.messages.context_processors.messages',
89 ],
90 },
91 },
92]
93
94WSGI_APPLICATION = 'sportpro.wsgi.application'
95
96
97REST_FRAMEWORK = {
98 'DEFAULT_AUTHENTICATION_CLASSES': (
99 'rest_framework.authentication.TokenAuthentication',
100 'rest_framework_simplejwt.authentication.JWTAuthentication',
101 ),
102 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend']
103}
104
105
106AUTH_USER_MODEL = 'user.User'
107
108
109# Database
110# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
111
112DATABASES = {
113 'default': {
114 'ENGINE': 'django.db.backends.postgresql_psycopg2',
115 'NAME': env('NAME'),
116 'USER': env('USER'),
117 'PASSWORD': env('PASSWORD'),
118 'HOST': env('HOST'),
119 'PORT': env('PORT'),
120 }
121}
122
123# DATABASES = {
124# 'default': env.db(),
125# }
126
127
128# Password validation
129# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
130
131AUTH_PASSWORD_VALIDATORS = [
132 {
133 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
134 },
135 {
136 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
137 },
138 {
139 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
140 },
141 {
142 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
143 },
144]
145
146
147# Internationalization
148# https://docs.djangoproject.com/en/2.2/topics/i18n/
149
150LANGUAGE_CODE = 'en-us'
151
152TIME_ZONE = 'UTC'
153
154USE_I18N = True
155
156USE_L10N = True
157
158USE_TZ = True
159
160
161# Static files (CSS, JavaScript, Images)
162# https://docs.djangoproject.com/en/2.2/howto/static-files/
163
164STATIC_URL = '/static/'
165STATIC_ROOT = os.path.join(BASE_DIR, 'static')
166MEDIA_URL = '/media/'
167MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
168
169django_heroku.settings(locals())
170
171
172cred = credentials.Certificate(
173 os.path.join(settings.BASE_DIR, "sportpro-c5b31-firebase-adminsdk-rvvh7-1a28b7dc64.json"))
174firebase_admin.initialize_app(cred)
175
176JET_SIDE_MENU_COMPACT = True
177