Skip to content

Instantly share code, notes, and snippets.

@flaviolopes
Created June 21, 2017 22:41
Show Gist options
  • Save flaviolopes/95788b66803f1d4d2a16c6087407fccf to your computer and use it in GitHub Desktop.
Save flaviolopes/95788b66803f1d4d2a16c6087407fccf to your computer and use it in GitHub Desktop.
settings.py
"""
Django settings for eventex project.
Generated by 'django-admin startproject' using Django 1.11.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
from decouple import config, Csv
from dj_database_url import parse as dburl
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
##SECRET_KEY = '8gobs@=8uu=dq3pnuu*kp2o((a4$yyhh%r7(j@u#c&5$+)z=6!'
SECRET_KEY = config('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
##DEBUG = True
DEBUG = config('DEBUG', default=False, cast=bool)
# ALLOWED_HOSTS = ['127.0.0.1', '.localhost', '.herokuapp.com'] ## Os dois primeiros endereços são para serem usados em
# ## ambiente de testes, já o '.herokuapp.com' para ser usado
# ## em produção
## Aqui ele trocou como era realizado acima, passando tudo para o decouple que onde defimos dentro do ".ev" quais as
## listas de hosts/domínios que podem acessar nossa APP
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=[], cast=Csv())
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'eventex.core',
'eventex.subscriptions',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'eventex.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'eventex.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
default_dburl = 'sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3')
DATABASES = {
'default': config('DABASE_URL', default=default_dburl, cast=dburl),
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
# LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'pt-br'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # Este é o diretorio onde o Django vai copiar todos
# arquivos estáticos do projeto
## Configuração de E-mail
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' ## Aqui só para testar usando o interno do Django
## Aqui iremos configurar para usar as variaveis do DECOUPLE, pois usaremos e-mail de verdade no Heroku
EMAIL_BACKEND = config('EMAIL_BACKEND')
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_PORT = config('EMAIL_PORT', cast=int)
EMAIL_USE_TLS = config('EMAIL_USE_TLS', cast=bool)
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_HOST_PASSWD = config('EMAIL_HOST_PASSWD')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment