settings.py 4.16 KB
Newer Older
dorothee.kueppers's avatar
dorothee.kueppers committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""
Django settings for oos_2020_todo project.

Generated by 'django-admin startproject' using Django 3.0.7.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
dorothee.kueppers's avatar
dorothee.kueppers committed
16
import django_heroku
dorothee.kueppers's avatar
dorothee.kueppers committed
17
18
import dj_database_url
import dotenv
dorothee.kueppers's avatar
dorothee.kueppers committed
19

dorothee.kueppers's avatar
dorothee.kueppers committed
20
21
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

dorothee.kueppers's avatar
dorothee.kueppers committed
22
23
24
dotenv_file = os.path.join(BASE_DIR, ".env")
if os.path.isfile(dotenv_file):
    dotenv.load_dotenv(dotenv_file)
dorothee.kueppers's avatar
dorothee.kueppers committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '8f&^^5razouamp=m1-_a+pnd_m+4l5+yspjq2b_9q8v@45+!2!'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
dorothee.kueppers's avatar
dorothee.kueppers committed
40
    'django_crontab',
dorothee.kueppers's avatar
dorothee.kueppers committed
41
    'django.contrib.admin',
dorothee.kueppers's avatar
dorothee.kueppers committed
42
    'django.contrib.sites',
dorothee.kueppers's avatar
dorothee.kueppers committed
43
44
45
46
47
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
dorothee.kueppers's avatar
dorothee.kueppers committed
48
    'todo',
49
50
    'bootstrap4',
    'recurrence',
dorothee.kueppers's avatar
dorothee.kueppers committed
51
52
53
54

    'allauth',
    'allauth.account',
    'allauth.socialaccount',
dorothee.kueppers's avatar
dorothee.kueppers committed
55
56
57
58
59
60
61
62
63
64
]

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',
dorothee.kueppers's avatar
dorothee.kueppers committed
65
66
    'whitenoise.middleware.WhiteNoiseMiddleware',

dorothee.kueppers's avatar
dorothee.kueppers committed
67
68
69
70
71
72
73
]

ROOT_URLCONF = 'oos_2020_todo.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
dorothee.kueppers's avatar
dorothee.kueppers committed
74
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
dorothee.kueppers's avatar
dorothee.kueppers committed
75
76
77
78
79
80
81
82
83
84
85
86
        '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',
            ],
        },
    },
]

dorothee.kueppers's avatar
dorothee.kueppers committed
87
SITE_ID = 1
dorothee.kueppers's avatar
dorothee.kueppers committed
88

dorothee.kueppers's avatar
dorothee.kueppers committed
89
90
91
92
93
94
95
96
97
AUTHENTICATION_BACKENDS = [
    # Needed to login by username in Django admin, regardless of `allauth`
    'django.contrib.auth.backends.ModelBackend',

    # `allauth` specific authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
]

WSGI_APPLICATION = 'oos_2020_todo.wsgi.application'
dorothee.kueppers's avatar
dorothee.kueppers committed
98
99
100
101

# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

dorothee.kueppers's avatar
dorothee.kueppers committed
102
103
104
105
106
107
108
109
110
# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.sqlite3',
#         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#     }
# }

DATABASES = {}
DATABASES['default'] = dj_database_url.config(conn_max_age=600)
dorothee.kueppers's avatar
dorothee.kueppers committed
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

# Password validation
# https://docs.djangoproject.com/en/3.0/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/3.0/topics/i18n/

dorothee.kueppers's avatar
dorothee.kueppers committed
133
LANGUAGE_CODE = 'de-de'
dorothee.kueppers's avatar
dorothee.kueppers committed
134

dorothee.kueppers's avatar
dorothee.kueppers committed
135
TIME_ZONE = 'Europe/Berlin'
dorothee.kueppers's avatar
dorothee.kueppers committed
136
137
138
139
140
141
142

USE_I18N = True

USE_L10N = True

USE_TZ = True

dorothee.kueppers's avatar
dorothee.kueppers committed
143
144
RECURRENCE_USE_TZ = True

dorothee.kueppers's avatar
dorothee.kueppers committed
145
146
147
148
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
149
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
dorothee.kueppers's avatar
dorothee.kueppers committed
150
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
151

152
CRONJOBS = [
dorothee.kueppers's avatar
dorothee.kueppers committed
153
    ('0 8 * * *', 'todo.cron.email_todays_todos')
dorothee.kueppers's avatar
dorothee.kueppers committed
154
155
]

dorothee.kueppers's avatar
dorothee.kueppers committed
156
157
# Activate Django-Heroku.
django_heroku.settings(locals())
dorothee.kueppers's avatar
dorothee.kueppers committed
158

dorothee.kueppers's avatar
dorothee.kueppers committed
159
del DATABASES['default']['OPTIONS']['sslmode']