· 4 years ago · Sep 07, 2021, 10:46 AM
1"""
2Django settings for learning_log project.
3
4Generated by 'django-admin startproject' using Django 3.2.6.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/3.2/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/3.2/ref/settings/
11"""
12
13from pathlib import Path
14
15#My settings
16LOGIN_URL = '/users/login/'
17
18#Settings for django-bootstrap3
19BOOTSTRAP3 = {
20 'include_jquery': True,
21}
22#Heroku settings
23import os
24if os.getcwd() == '/app':
25 import dj_database_url
26 DATABASES = {
27 'default': dj_database_url.config(default='postgres://localhost')
28 }
29
30 # Honor the 'X-Forwarded-Proto' header for request.is_secure().
31 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
32
33 #Allow all host headers.
34 ALLOWED_HOSTS = ['*']
35
36 # Static asset configuration
37 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
38 STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
39 STATIC_URL = '/static/'
40
41 #Extra places for collecting
42 STATICFILES_DIRS = (
43 os.path.join(BASE_DIR, 'static'),
44 )
45# Build paths inside the project like this: BASE_DIR / 'subdir'.
46BASE_DIR = Path(__file__).resolve().parent.parent
47
48
49# Quick-start development settings - unsuitable for production
50# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
51
52# SECURITY WARNING: keep the secret key used in production secret!
53SECRET_KEY = 'django-insecure-2(w8g=6=o80!*qveov&^q^4+z*kp99ifymu_zri$@y-7%x-'
54
55# SECURITY WARNING: don't run with debug turned on in production!
56DEBUG = True
57
58ALLOWED_HOSTS = ['agile-retreat-63468.herokuapp.com',]
59
60
61# Application definition
62
63INSTALLED_APPS = [
64 'django.contrib.admin',
65 'django.contrib.auth',
66 'django.contrib.contenttypes',
67 'django.contrib.sessions',
68 'django.contrib.messages',
69 'django.contrib.staticfiles',
70
71 #Third party apps
72 'bootstrap3',
73
74
75
76 # My apps
77 'learning_logs',
78 'users',
79]
80
81MIDDLEWARE = [
82 'django.middleware.security.SecurityMiddleware',
83 'django.contrib.sessions.middleware.SessionMiddleware',
84 'django.middleware.common.CommonMiddleware',
85 'django.middleware.csrf.CsrfViewMiddleware',
86 'django.contrib.auth.middleware.AuthenticationMiddleware',
87 'django.contrib.messages.middleware.MessageMiddleware',
88 'django.middleware.clickjacking.XFrameOptionsMiddleware',
89]
90
91ROOT_URLCONF = 'learning_log.urls'
92
93TEMPLATES = [
94 {
95 'BACKEND': 'django.template.backends.django.DjangoTemplates',
96 'DIRS': [],
97 'APP_DIRS': True,
98 'OPTIONS': {
99 'context_processors': [
100 'django.template.context_processors.debug',
101 'django.template.context_processors.request',
102 'django.contrib.auth.context_processors.auth',
103 'django.contrib.messages.context_processors.messages',
104 ],
105 },
106 },
107]
108
109WSGI_APPLICATION = 'learning_log.wsgi.application'
110
111
112# Database
113# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
114
115DATABASES = {
116 'default': {
117 'ENGINE': 'django.db.backends.sqlite3',
118 'NAME': BASE_DIR / 'db.sqlite3',
119 }
120}
121
122
123# Password validation
124# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
125
126AUTH_PASSWORD_VALIDATORS = [
127 {
128 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
129 },
130 {
131 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
132 },
133 {
134 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
135 },
136 {
137 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
138 },
139]
140
141
142# Internationalization
143# https://docs.djangoproject.com/en/3.2/topics/i18n/
144
145LANGUAGE_CODE = 'en-us'
146
147TIME_ZONE = 'UTC'
148
149USE_I18N = True
150
151USE_L10N = True
152
153USE_TZ = True
154
155
156# Static files (CSS, JavaScript, Images)
157# https://docs.djangoproject.com/en/3.2/howto/static-files/
158
159STATIC_URL = '/static/'
160
161# Default primary key field type
162# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
163
164DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
165