· 7 years ago · Sep 12, 2018, 09:10 PM
1import os
2import posixpath
3from os import environ
4
5# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
6BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
7
8
9
10# Quick-start development settings - unsuitable for production
11# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
12
13# SECURITY WARNING: keep the secret key used in production secret!
14SECRET_KEY = 'A SECRET'
15
16DEBUG = True
17
18ALLOWED_HOSTS = ['*']
19
20
21
22
23SITE_TITLE = "Penguiness"
24SITE_TAGLINE = "Amazing records for amazing species"
25
26# Application definition
27
28INSTALLED_APPS = [
29 'app',
30 # Add your apps here to enable them
31 'django.contrib.admin',
32 'django.contrib.auth',
33 'django.contrib.contenttypes',
34 'django.contrib.sessions',
35 'django.contrib.messages',
36 'django.contrib.staticfiles',
37 'compressor',
38 'gunicorn'
39]
40
41MIDDLEWARE_CLASSES = [
42 'django.middleware.security.SecurityMiddleware',
43 'django.contrib.sessions.middleware.SessionMiddleware',
44 'django.middleware.common.CommonMiddleware',
45 'django.middleware.csrf.CsrfViewMiddleware',
46 'django.contrib.auth.middleware.AuthenticationMiddleware',
47 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
48 'django.contrib.messages.middleware.MessageMiddleware',
49 'django.middleware.clickjacking.XFrameOptionsMiddleware',
50 'whitenoise.middleware.WhiteNoiseMiddleware',
51]
52
53ROOT_URLCONF = 'Penguinness.urls'
54
55
56# Static files (CSS, JavaScript, Images)
57# https://docs.djangoproject.com/en/1.9/howto/static-files/
58
59
60STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
61
62STATIC_URL = '/static/'
63
64STATIC_ROOT = posixpath.join(*(BASE_DIR.split(os.path.sep) + ['app/static']))
65
66PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__))
67PROJECT_APP = os.path.basename(PROJECT_APP_PATH)
68PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
69
70
71TEMPLATES = [
72 {
73 'BACKEND': 'django.template.backends.django.DjangoTemplates',
74 'DIRS': [os.path.join(PROJECT_ROOT, "app/templates")],
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 'app.context_processors.global_settings',
83 ],
84 },
85 },
86]
87
88WSGI_APPLICATION = 'Penguinness.wsgi.application'
89
90
91# Database
92# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
93
94# DATABASES = {
95# 'default': {
96# DATABASE STUFF
97# }
98# }
99
100
101
102
103
104SECURE_PROXY_SSL_HEADER = (
105 "HTTP_X_FORWARDED_PROTO",
106 "https"
107 )
108
109
110
111
112
113# Password validation
114# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
115
116AUTH_PASSWORD_VALIDATORS = [
117 {
118 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
119 },
120 {
121 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
122 },
123 {
124 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
125 },
126 {
127 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
128 },
129]
130
131
132# Internationalization
133# https://docs.djangoproject.com/en/1.9/topics/i18n/
134
135LANGUAGE_CODE = 'en-us'
136
137TIME_ZONE = 'UTC'
138
139USE_I18N = True
140
141USE_L10N = True
142
143USE_TZ = True
144
145
146EMAIL_USE_TLS = True
147EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
148EMAIL_HOST = 'smtp.gmail.com'
149EMAIL_HOST_PASSWORD = PASSWORD #my gmail password
150EMAIL_HOST_USER = EMAIL #my gmail username
151EMAIL_PORT = 587
152DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
153
154
155import dj_database_url
156db_from_env = dj_database_url.config(conn_max_age=500)
157DATABASES['default'].update(db_from_env)