Keine Beschreibung

settings.py 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. """
  2. Django settings for network_report project.
  3. Generated by 'django-admin startproject' using Django 4.1.5.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/4.1/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/4.1/ref/settings/
  8. """
  9. from pathlib import Path
  10. import os
  11. import os
  12. import environ
  13. from pprint import pprint
  14. import django
  15. from django.utils.encoding import smart_str
  16. django.utils.encoding.smart_text = smart_str
  17. env = environ.Env()
  18. environ.Env.read_env()
  19. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  20. BASE_DIR = Path(__file__).resolve().parent.parent
  21. # Quick-start development settings - unsuitable for production
  22. # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
  23. # SECURITY WARNING: keep the secret key used in production secret!
  24. SECRET_KEY = 'django-insecure-e197skh+hf2!q)k&z9a*=#_mnr4y(+x@i856z76oxpz!19%3u='
  25. # SECURITY WARNING: don't run with debug turned on in production!
  26. DEBUG = True
  27. mode = os.getenv('MODE')
  28. pprint(f"==== {mode} ====")
  29. if mode == "dev" or mode == "":
  30. DEBUG = True
  31. else:
  32. DEBUG = False
  33. ALLOWED_HOSTS = ['*']
  34. # Application definition
  35. INSTALLED_APPS = [
  36. 'django.contrib.admin',
  37. 'django.contrib.auth',
  38. 'django.contrib.contenttypes',
  39. 'django.contrib.sessions',
  40. 'django.contrib.messages',
  41. 'django.contrib.staticfiles',
  42. 'django.contrib.humanize',
  43. 'django.contrib.postgres',
  44. 'crispy_forms',
  45. "crispy_bootstrap5",
  46. "django_browser_reload",
  47. 'widget_tweaks',
  48. 'django_bootstrap_breadcrumbs',
  49. 'django_filters',
  50. 'django_yarnpkg',
  51. 'backend.apps.BackendConfig',
  52. ]
  53. MIDDLEWARE = [
  54. 'django.middleware.security.SecurityMiddleware',
  55. 'django.contrib.sessions.middleware.SessionMiddleware',
  56. 'django.middleware.common.CommonMiddleware',
  57. 'django.middleware.csrf.CsrfViewMiddleware',
  58. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  59. 'django.contrib.messages.middleware.MessageMiddleware',
  60. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  61. "django_browser_reload.middleware.BrowserReloadMiddleware",
  62. ]
  63. ROOT_URLCONF = 'network_report.urls'
  64. TEMPLATES = [
  65. {
  66. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  67. 'DIRS': [os.path.join(BASE_DIR,'templates')],
  68. 'APP_DIRS': True,
  69. 'OPTIONS': {
  70. 'context_processors': [
  71. 'django.template.context_processors.debug',
  72. 'django.template.context_processors.request',
  73. 'django.contrib.auth.context_processors.auth',
  74. 'django.contrib.messages.context_processors.messages',
  75. ],
  76. },
  77. },
  78. ]
  79. WSGI_APPLICATION = 'network_report.wsgi.application'
  80. # Database
  81. # https://docs.djangoproject.com/en/4.1/ref/settings/#databases
  82. DATABASES = {
  83. 'default': {
  84. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
  85. 'NAME': env("POSTGRES_NAME"),
  86. 'USER': env("POSTGRES_USER"),
  87. 'PASSWORD': env("POSTGRES_PASSWORD"),
  88. 'HOST': 'db',
  89. 'PORT': '5432',
  90. }
  91. }
  92. # Password validation
  93. # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
  94. AUTH_PASSWORD_VALIDATORS = [
  95. {
  96. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  97. },
  98. {
  99. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  100. },
  101. {
  102. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  103. },
  104. {
  105. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  106. },
  107. ]
  108. # Internationalization
  109. # https://docs.djangoproject.com/en/4.1/topics/i18n/
  110. LANGUAGE_CODE = 'en-us'
  111. TIME_ZONE = 'UTC'
  112. USE_I18N = True
  113. USE_TZ = True
  114. # Static files (CSS, JavaScript, Images)
  115. # https://docs.djangoproject.com/en/4.1/howto/static-files/
  116. STATIC_URL = 'static/'
  117. # Default primary key field type
  118. # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
  119. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  120. MEDIA_URL = '/media/'
  121. MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
  122. CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
  123. CRISPY_TEMPLATE_PACK = "bootstrap5"
  124. STATICFILES_DIRS = [
  125. BASE_DIR / "static",
  126. ]
  127. STATIC_ROOT = BASE_DIR / 'staticfiles'
  128. STATICFILES_FINDERS = [
  129. 'django.contrib.staticfiles.finders.FileSystemFinder',
  130. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  131. 'django_yarnpkg.finders.NodeModulesFinder',
  132. 'compressor.finders.CompressorFinder'
  133. ]
  134. YARN_INSTALLED_APPS = (
  135. 'bootstrap@^5.0',
  136. 'underscore@^1.6.1',
  137. 'alpinejs@^3.10.5',
  138. 'axios@^1.2.2',
  139. 'tailwindcss@^3.2.4',
  140. 'sortablejs@^1.1.5',
  141. 'chart.js@^4.1.1',
  142. 'datatables.net-bs5',
  143. 'lightbox2',
  144. 'granim',
  145. 'slick-carousel',
  146. 'mjml',
  147. 'tailwind-color-palette',
  148. 'paper-css'
  149. )