You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
3.9 KiB

  1. """
  2. Django settings for foerderbarometer project.
  3. Generated by 'django-admin startproject' using Django 3.1.1.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/3.1/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/3.1/ref/settings/
  8. """
  9. import json
  10. import os
  11. from pathlib import Path
  12. from django.core.exceptions import ImproperlyConfigured
  13. # prefix for urls in mails
  14. URLPREFIX = 'http://localhost:8000'
  15. # mails in development go to stdout
  16. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  17. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  18. BASE_DIR = Path(__file__).resolve().parent.parent
  19. # get secrets
  20. with open(os.path.join(BASE_DIR, 'secrets.json')) as secrets_file:
  21. secrets = json.load(secrets_file)
  22. def get_secret(setting, secrets=secrets):
  23. """Get secret setting or fail with ImproperlyConfigured"""
  24. try:
  25. return secrets[setting]
  26. except KeyError:
  27. raise ImproperlyConfigured("Set the {} setting".format(setting))
  28. # Quick-start development settings - unsuitable for production
  29. # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
  30. # SECURITY WARNING: keep the secret key used in production secret!
  31. SECRET_KEY = '*&7p9#_n$@^%0z49s+7jpy@+j1rw_hqh05knyd6y2*!0)r&b6h'
  32. # SECURITY WARNING: don't run with debug turned on in production!
  33. DEBUG = True
  34. STATIC_ROOT = BASE_DIR / 'staticfiles'
  35. ALLOWED_HOSTS = ['*']
  36. # Application definition
  37. INSTALLED_APPS = [
  38. 'input.apps.InputConfig',
  39. 'django.contrib.admin',
  40. 'django.contrib.auth',
  41. 'django.contrib.contenttypes',
  42. 'django.contrib.sessions',
  43. 'django.contrib.messages',
  44. 'django.contrib.staticfiles',
  45. 'formtools',
  46. ]
  47. MIDDLEWARE = [
  48. 'django.middleware.security.SecurityMiddleware',
  49. 'whitenoise.middleware.WhiteNoiseMiddleware',
  50. 'django.contrib.sessions.middleware.SessionMiddleware',
  51. 'django.middleware.locale.LocaleMiddleware',
  52. 'django.middleware.common.CommonMiddleware',
  53. 'django.middleware.csrf.CsrfViewMiddleware',
  54. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  55. 'django.contrib.messages.middleware.MessageMiddleware',
  56. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  57. ]
  58. ROOT_URLCONF = 'foerderbarometer.urls'
  59. TEMPLATES = [
  60. {
  61. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  62. 'DIRS': [],
  63. 'APP_DIRS': True,
  64. 'OPTIONS': {
  65. 'context_processors': [
  66. 'django.template.context_processors.debug',
  67. 'django.template.context_processors.request',
  68. 'django.contrib.auth.context_processors.auth',
  69. 'django.contrib.messages.context_processors.messages',
  70. ],
  71. },
  72. },
  73. ]
  74. WSGI_APPLICATION = 'foerderbarometer.wsgi.application'
  75. # Database
  76. # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
  77. DATABASES = {
  78. 'default': {
  79. 'ENGINE': 'django.db.backends.sqlite3',
  80. 'NAME': BASE_DIR / 'db.sqlite3',
  81. 'PASSWORD': get_secret('DATABASE_PASSWORD')
  82. }
  83. }
  84. # Password validation
  85. # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
  86. AUTH_PASSWORD_VALIDATORS = [
  87. {
  88. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  89. },
  90. {
  91. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  92. },
  93. {
  94. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  95. },
  96. {
  97. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  98. },
  99. ]
  100. # Internationalization
  101. # https://docs.djangoproject.com/en/3.1/topics/i18n/
  102. LANGUAGE_CODE = 'en-us'
  103. TIME_ZONE = 'UTC'
  104. USE_I18N = True
  105. USE_L10N = True
  106. USE_TZ = True
  107. # Static files (CSS, JavaScript, Images)
  108. # https://docs.djangoproject.com/en/3.1/howto/static-files/
  109. STATIC_URL = '/static/'
  110. # needed since django 3.2
  111. DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'