· 6 years ago · Feb 18, 2019, 03:12 PM
1"""
2Django settings for PiVoz project.
3
4Generated by 'django-admin startproject' using Django 2.1.3.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/2.1/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.1/ref/settings/
11"""
12
13import os
14import dj_database_url
15
16# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18
19
20# Quick-start development settings - unsuitable for production
21# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
22
23# SECURITY WARNING: keep the secret key used in production secret!
24SECRET_KEY = '@+z$b_^*hq5*8nl2*c#0$433!3=w^%2s2(#fiaja7!c9aii&)o'
25
26# SECURITY WARNING: don't run with debug turned on in production!
27DEBUG = False
28
29
30ALLOWED_HOSTS = ['localhost', '127.0.0.1', '111.222.333.444', 'mywebsite.com']
31
32
33# Application definition
34
35INSTALLED_APPS = [
36 'jet', # https://github.com/geex-arts/django-jet
37 'jet.dashboard',
38 'django_filters', # https://github.com/carltongibson/django-filter
39 'django_admin_row_actions', # https://github.com/DjangoAdminHackers/django-admin-row-actions
40 'django_extensions',
41 'sendgrid', # https://github.com/sendgrid
42 'django_registration',
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 'django_google_maps', # https://github.com/madisona/django-google-maps
50 'django_cleanup.apps.CleanupConfig', # https://github.com/un1t/django-cleanup
51 'phonenumber_field', # https://github.com/stefanfoulis/django-phonenumber-field
52 'imagekit', # https://github.com/matthewwithanm/django-imagekit
53 'Galeria',
54 #'storages',
55]
56
57MIDDLEWARE = [
58 'django.middleware.security.SecurityMiddleware',
59 'django.contrib.sessions.middleware.SessionMiddleware',
60 'django.middleware.common.CommonMiddleware',
61 'django.middleware.csrf.CsrfViewMiddleware',
62 'django.contrib.auth.middleware.AuthenticationMiddleware',
63 'django.contrib.messages.middleware.MessageMiddleware',
64 'django.middleware.clickjacking.XFrameOptionsMiddleware',
65 'whitenoise.middleware.WhiteNoiseMiddleware',
66]
67
68ROOT_URLCONF = 'PiVoz.urls'
69
70TEMPLATES = [
71 {
72 'BACKEND': 'django.template.backends.django.DjangoTemplates',
73 'DIRS': [os.path.join(BASE_DIR, 'templates')]
74 ,
75 'APP_DIRS': True,
76 'OPTIONS': {
77 'context_processors': [
78 'django.template.context_processors.debug',
79 'django.template.context_processors.request',
80 'django.contrib.auth.context_processors.auth',
81 'django.contrib.messages.context_processors.messages',
82 ],
83 },
84 },
85]
86
87WSGI_APPLICATION = 'PiVoz.wsgi.application'
88
89
90# Database
91# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
92
93DATABASES = {
94 'default': {
95 'ENGINE': 'django.db.backends.sqlite3',
96 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
97 }
98}
99
100# DATABASES = {
101# 'default': {
102# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
103# 'NAME': 'PiVoz',
104# 'USER': 'name',
105# 'PASSWORD': '',
106# 'HOST': 'localhost',
107# 'PORT': '',
108# }
109# }
110
111
112# # AWS S3 Config
113# AWS_S3_OBJECT_PARAMETERS = {
114# 'Expires': 'Thu, 31 Dec 2099 20:00:00 GMT',
115# 'CacheControl': 'max-age=94608000',
116# }
117#
118# AWS_STORAGE_BUCKET_NAME = 'pivoz'
119# AWS_S3_REGION_NAME = 'eu-west-1' # e.g. us-east-2
120# AWS_ACCESS_KEY_ID = 'AKIAIPKETOZWAMSE5UUQ'
121# AWS_SECRET_ACCESS_KEY = 'fS8TFbNWUfxaazEBXEv7MBLIL08DuJi/8smLsGJ2'
122#
123# # Tell django-storages the domain to use to refer to static files.
124# AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
125#
126# # Tell the staticfiles app to use S3Boto3 storage when writing the collected static files (when
127# # you run `collectstatic`).
128# STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
129
130# Password validation
131# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
132
133AUTH_PASSWORD_VALIDATORS = [
134 {
135 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
136 },
137 {
138 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
139 },
140 {
141 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
142 },
143 {
144 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
145 },
146]
147
148AUTHENTICATION_BACKENDS = [
149 'django.contrib.auth.backends.ModelBackend',
150 #'PiVoz.backends.RFIDAuthentication',
151]
152
153
154
155# Email Configuration
156# Sendgrid : https://sendgrid.com/docs/for-developers/sending-email/django/
157
158
159EMAIL_BACKEND = "sgbackend.SendGridBackend"
160SENDGRID_API_KEY = "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"
161
162# EMAIL_HOST = 'smtp.sendgrid.net'
163# EMAIL_HOST_USER = 'sendgrid_username'
164# EMAIL_HOST_PASSWORD = 'sendgrid_password'
165# EMAIL_PORT = 587
166# EMAIL_USE_TLS = True
167
168""" Configuration of Django Registration """
169
170ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window
171REGISTRATION_OPEN = True
172
173
174# Django Google Maps API KEY
175
176GOOGLE_MAPS_API_KEY = 'AIzaSyAurb5ZABXUxF0QGpr2cyTEf_DJVKTD3k4'
177
178# Celery Config
179CELERY_TASK_SERIALIZER = 'json'
180#CELERY_RESULT_BACKEND = 'django-db'
181#CELERY_BROKER_URL = 'django://'
182#INSTALLED_APPS += ('kombu.transport.django', )
183
184# Heroku Config
185
186# db_from_env = dj_database_url.config(conn_max_age=500)
187# DATABASES['default'].update(db_from_env)
188
189# Internationalization
190# https://docs.djangoproject.com/en/2.1/topics/i18n/
191
192LANGUAGE_CODE = 'es-es'
193
194TIME_ZONE = 'Europe/Madrid'
195
196USE_I18N = True
197
198USE_L10N = True
199
200USE_TZ = True
201
202
203# Static files (CSS, JavaScript, Images)
204# https://docs.djangoproject.com/en/2.1/howto/static-files/
205
206AUTH_USER_MODEL = 'Galeria.MyUser'
207
208LOGIN_REDIRECT_URL = 'home'
209
210
211LOGIN_URL = "http://127.0.0.1:8000/accounts/login/"
212
213
214STATICFILES_DIRS = (
215 os.path.join(BASE_DIR, "static"),
216)
217
218STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
219
220STATIC_URL = '/static/'
221STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
222
223MEDIA_URL = '/media/'
224MEDIA_ROOT = os.path.join(BASE_DIR, 'media')