· 6 years ago · Sep 05, 2019, 12:10 PM
1"""
2Django settings for footters project.
3
4Generated by 'django-admin startproject' using Django 2.2.5.
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
14import smuggler
15import django_heroku
16import whitenoise
17
18# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
19BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
20
21
22# Quick-start development settings - unsuitable for production
23# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
24
25# SECURITY WARNING: keep the secret key used in production secret!
26SECRET_KEY = '6mlgtjs6!vax6(zn@(d%3oy_6iv)%he*tj6b-@zwx(#zfi*#f2'
27
28if 'DYNO' in os.environ:
29 BASEURL = 'https://footters-manager.herokuapp.com/'
30# SECURITY WARNING: don't run with debug turned on in production!
31if 'DYNO' in os.environ:
32 DEBUG = False
33else:
34 DEBUG = False
35
36if 'DYNO' in os.environ:
37 SECURE_SSL_REDIRECT = True
38 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
39
40ALLOWED_HOSTS = ['localhost', '127.0.0.1','http://footters-manager.herokuapp.com/']
41VERSION=2
42
43
44
45# Application definition
46
47INSTALLED_APPS = [
48 'admin_shortcuts',
49 'django.contrib.admin',
50 'django.contrib.auth',
51 'django.contrib.contenttypes',
52 'django.contrib.sessions',
53 'django.contrib.messages',
54 'django.contrib.staticfiles',
55 'footters_app.apps.FoottersAppConfig',
56 "colorfield",
57 'smuggler',
58 'rest_framework',
59]
60
61MIDDLEWARE = [
62 'django.middleware.security.SecurityMiddleware',
63 'whitenoise.middleware.WhiteNoiseMiddleware',
64 'django.contrib.sessions.middleware.SessionMiddleware',
65 'django.middleware.common.CommonMiddleware',
66 'django.middleware.csrf.CsrfViewMiddleware',
67 'django.contrib.auth.middleware.AuthenticationMiddleware',
68 'django.contrib.messages.middleware.MessageMiddleware',
69 'django.middleware.clickjacking.XFrameOptionsMiddleware',
70]
71
72SMUGGLER_FIXTURE_DIR = 'footters_app/fixtures'
73
74ROOT_URLCONF = 'footters.urls'
75
76TEMPLATES = [
77 {
78 'BACKEND': 'django.template.backends.django.DjangoTemplates',
79 'DIRS': [os.path.join(BASE_DIR, 'templates')]
80 ,
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 = 'footters.wsgi.application'
94
95
96ADMIN_SHORTCUTS = [
97 {
98 'shortcuts': [
99 {
100 'url': '/admin',
101 'icon': 'home'
102 },
103 {
104 'url_name': 'admin:logout',
105 },
106 {
107 'title': 'Usuarios',
108 'url_name': 'admin:auth_user_changelist',
109 'count': 'footters_app.admin_methods.count_users',
110 },
111 {
112 'title': 'Grupos',
113 'url_name': 'admin:auth_group_changelist',
114 'count': 'footters_app.admin_methods.count_groups',
115 },
116 {
117 'title': 'Añadir usuario',
118 'url_name': 'admin:auth_user_add',
119 'has_perms': 'footters_app.admin_methods.has_perms_to_users',
120 },
121 ]
122 },
123 {
124 'title': 'Utilidades',
125 'shortcuts': [
126 {
127 'title': 'Documentación',
128 'icon': 'book',
129 'url_name': 'admin:index',
130 },
131 {
132 'title': 'Descargar datos',
133 'icon': 'download',
134 'url_name': ['dumpdata', "footters_app,auth"],
135 },
136 {
137 'title': 'Cargar datos',
138 'icon': 'upload',
139 'url_name': 'load-data',
140 # 'count_new': '3',
141 },
142 {
143 'title': 'Añadir equipo real',
144 'url_name': 'admin:footters_app_equiporeal_add',
145 'icon': 'shield-alt'
146 },
147 {
148 'title': 'Añadir jugador',
149 'url_name': 'admin:footters_app_jugador_add',
150 'icon': 'futbol'
151 },
152 ]
153 },
154]
155
156REST_FRAMEWORK = {
157 # Use Django's standard `django.contrib.auth` permissions,
158 # or allow read-only access for unauthenticated users.
159 'DEFAULT_PERMISSION_CLASSES': [
160 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
161 ]
162}
163
164ADMIN_SHORTCUTS_SETTINGS = {
165 'show_on_all_pages': True,
166 'hide_app_list': False,
167 'open_new_window': False,
168}
169
170# Database
171# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
172
173DATABASES = {
174 'default': {
175 'ENGINE': 'django.db.backends.sqlite3',
176 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
177 }
178}
179
180
181django_heroku.settings(locals())
182
183
184# Password validation
185# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
186
187AUTH_PASSWORD_VALIDATORS = [
188 {
189 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
190 },
191 {
192 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
193 },
194 {
195 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
196 },
197 {
198 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
199 },
200]
201
202
203# Internationalization
204# https://docs.djangoproject.com/en/2.2/topics/i18n/
205
206LANGUAGE_CODE = 'es-es'
207
208TIME_ZONE = 'UTC'
209
210USE_I18N = True
211
212USE_L10N = True
213
214USE_TZ = True
215
216
217# Static files (CSS, JavaScript, Images)
218# https://docs.djangoproject.com/en/2.2/howto/static-files/
219
220WSGI_APPLICATION = 'footters_app.wsgi.application'
221
222
223STATICFILES_DIRS = [
224 os.path.join(BASE_DIR, 'static')
225]
226PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
227STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')