Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Django settings for capstone project.
4Generated by 'django-admin startproject' using Django 3.1.2.
6For more information on this file, see
7https://docs.djangoproject.com/en/3.1/topics/settings/
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/3.1/ref/settings/
11"""
13from pathlib import Path
14import os
15from django.utils.translation import ugettext_lazy as _
17IS_HEROKU_ENV = True if os.environ.get('IS_HEROKU_ENV') == 'True' else False
19if IS_HEROKU_ENV:
20 import django_heroku
22# Build paths inside the project like this: BASE_DIR / 'subdir'.
23BASE_DIR = Path(__file__).resolve().parent.parent
25# Quick-start development settings - unsuitable for production
26# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
28# SECURITY WARNING: keep the secret key used in production secret!
29# SECURITY WARNING: don't run with debug turned on in production!
30# Database
31if IS_HEROKU_ENV:
32 SECRET_KEY = os.environ.get('SECRET_KEY')
33 DEBUG = True if os.environ.get('DEBUG') == 'True' else False
34 ALLOWED_HOSTS = [os.environ.get('ALLOWED_HOST_1')]
35 DATABASES = {
36 'default': {
37 'ENGINE': 'django.db.backends.postgresql_psycopg2',
38 'NAME': 'poli',
39 'USER': 'poliuser',
40 'PASSWORD': os.environ.get('DATABASE_PG_PASSWORD'),
41 'HOST': os.environ.get('DATABASE_PG_HOST'),
42 'PORT': os.environ.get('DATABASE_PG_PORT')
43 }
44 }
45 REST_FRAMEWORK = {
46 'DEFAULT_RENDERER_CLASSES': (
47 'rest_framework.renderers.JSONRenderer',
48 )
49 }
50else:
51 SECRET_KEY = 'pauh61syjzkx6$1d%euial5h&y-1=rlr39_z5e&g^7%!en)c$x'
52 DEBUG = True
53 ALLOWED_HOSTS = [os.environ.get('ALLOWED_HOST_1'), '0.0.0.0', '127.0.0.1']
54 DATABASES = {
55 'default': {
56 'ENGINE': 'django.db.backends.postgresql_psycopg2',
57 'NAME': 'poli',
58 'USER': 'poliuser',
59 'PASSWORD': 'poliuser',
60 'HOST': '127.0.0.1',
61 'PORT': '5432',
62 }
63 }
66# Application definition
68INSTALLED_APPS = [
69 'policon',
70 'policorp',
71 'django.contrib.admin',
72 'django.contrib.auth',
73 'django.contrib.contenttypes',
74 'django.contrib.sessions',
75 'django.contrib.messages',
76 'django.contrib.staticfiles',
77 'rest_framework',
78]
80MIDDLEWARE = [
81 'django.middleware.security.SecurityMiddleware',
82 'django.contrib.sessions.middleware.SessionMiddleware',
83 'django.middleware.common.CommonMiddleware',
84 'django.middleware.csrf.CsrfViewMiddleware',
85 'django.contrib.auth.middleware.AuthenticationMiddleware',
86 'django.contrib.messages.middleware.MessageMiddleware',
87 'django.middleware.clickjacking.XFrameOptionsMiddleware',
88]
90ROOT_URLCONF = 'capstone.urls'
92TEMPLATES = [
93 {
94 'BACKEND': 'django.template.backends.django.DjangoTemplates',
95 'DIRS': [],
96 'APP_DIRS': True,
97 'OPTIONS': {
98 'context_processors': [
99 'django.template.context_processors.debug',
100 'django.template.context_processors.request',
101 'django.contrib.auth.context_processors.auth',
102 'django.contrib.messages.context_processors.messages',
103 ],
104 },
105 },
106]
108WSGI_APPLICATION = 'capstone.wsgi.application'
110AUTH_USER_MODEL = 'policorp.User'
112# Password validation
113# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
115AUTH_PASSWORD_VALIDATORS = [
116 {
117 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
118 },
119 {
120 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
121 },
122 {
123 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
124 },
125 {
126 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
127 },
128]
131# Internationalization
132# https://docs.djangoproject.com/en/3.1/topics/i18n/
133# Default: ''en-us''
135LANGUAGE_CODE = 'es'
137TIME_ZONE = 'UTC'
139USE_I18N = True
141USE_L10N = True
143USE_TZ = True
146# Static files (CSS, JavaScript, Images)
147# https://docs.djangoproject.com/en/3.1/howto/static-files/
149STATIC_URL = os.path.join("/", "capstone", "static/")
151STATIC_ROOT = f"{BASE_DIR}{STATIC_URL}"
153if IS_HEROKU_ENV:
154 django_heroku.settings(locals())