settings.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. """
  2. Django settings for duhaz_blog project.
  3. Generated by 'django-admin startproject' using Django 3.2.4.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/3.2/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/3.2/ref/settings/
  8. """
  9. from pathlib import Path
  10. import os
  11. from dotenv import load_dotenv
  12. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  13. BASE_DIR = Path(__file__).resolve().parent.parent
  14. # Charger les variables d'environnement depuis le fichier .env
  15. load_dotenv(BASE_DIR / '.env')
  16. # Quick-start development settings - unsuitable for production
  17. # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
  18. # SECURITY WARNING: keep the secret key used in production secret!
  19. SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-changez-moi-en-production')
  20. # SECURITY WARNING: don't run with debug turned on in production!
  21. DEBUG = os.getenv('DEBUG', 'False') == 'True'
  22. ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
  23. # Application definition
  24. INSTALLED_APPS = [
  25. 'django.contrib.admin',
  26. 'django.contrib.auth',
  27. 'django.contrib.contenttypes',
  28. 'django.contrib.sessions',
  29. 'django.contrib.messages',
  30. 'django.contrib.staticfiles',
  31. 'tinymce', # Remplace trumbowyg
  32. 'import_export',
  33. 'crispy_forms',
  34. 'crispy_bootstrap4', # IMPORTANT : Ajouter pour Bootstrap 4
  35. 'core',
  36. 'blog',
  37. ]
  38. CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap4"
  39. CRISPY_TEMPLATE_PACK = 'bootstrap4'
  40. MIDDLEWARE = [
  41. 'django.middleware.security.SecurityMiddleware',
  42. 'django.contrib.sessions.middleware.SessionMiddleware',
  43. 'django.middleware.common.CommonMiddleware',
  44. 'django.middleware.csrf.CsrfViewMiddleware',
  45. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  46. 'django.contrib.messages.middleware.MessageMiddleware',
  47. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  48. ]
  49. ROOT_URLCONF = 'duhaz_blog.urls'
  50. TEMPLATES = [
  51. {
  52. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  53. 'DIRS': [],
  54. 'APP_DIRS': True,
  55. 'OPTIONS': {
  56. 'context_processors': [
  57. 'django.template.context_processors.debug',
  58. 'django.template.context_processors.request',
  59. 'django.contrib.auth.context_processors.auth',
  60. 'django.contrib.messages.context_processors.messages',
  61. ],
  62. },
  63. },
  64. ]
  65. WSGI_APPLICATION = 'duhaz_blog.wsgi.application'
  66. # Database
  67. # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
  68. DATABASES = {
  69. 'default': {
  70. 'ENGINE': 'django.db.backends.sqlite3',
  71. 'NAME': BASE_DIR / os.getenv('DATABASE_NAME', 'db.sqlite3'),
  72. }
  73. }
  74. # Password validation
  75. # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
  76. AUTH_PASSWORD_VALIDATORS = [
  77. {
  78. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  79. },
  80. {
  81. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  82. },
  83. {
  84. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  85. },
  86. {
  87. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  88. },
  89. ]
  90. # Internationalization
  91. # https://docs.djangoproject.com/en/3.2/topics/i18n/
  92. LANGUAGE_CODE = 'fr-FR'
  93. TIME_ZONE = 'Europe/Paris'
  94. USE_I18N = True
  95. USE_L10N = True
  96. USE_TZ = True
  97. # Static files (CSS, JavaScript, Images)
  98. # https://docs.djangoproject.com/en/3.2/howto/static-files/
  99. STATIC_URL = '/static/'
  100. STATICFILES_DIRS = [
  101. BASE_DIR / "static",
  102. ]
  103. STATIC_ROOT = BASE_DIR / 'staticfiles'
  104. # Media files
  105. MEDIA_URL = '/media/'
  106. MEDIA_ROOT = BASE_DIR / 'media'
  107. # Default primary key field type
  108. # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
  109. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  110. # Security settings (décommenter en production)
  111. # SECURE_SSL_REDIRECT = True
  112. # SESSION_COOKIE_SECURE = True
  113. # CSRF_COOKIE_SECURE = True
  114. # SECURE_BROWSER_XSS_FILTER = True
  115. # SECURE_CONTENT_TYPE_NOSNIFF = True
  116. # X_FRAME_OPTIONS = 'DENY'
  117. # TinyMCE Configuration
  118. TINYMCE_DEFAULT_CONFIG = {
  119. 'height': 500,
  120. 'width': '100%',
  121. 'cleanup_on_startup': True,
  122. 'custom_undo_redo_levels': 20,
  123. 'selector': 'textarea',
  124. 'theme': 'silver',
  125. 'plugins': '''
  126. textcolor save link image media preview codesample contextmenu
  127. table code lists fullscreen insertdatetime nonbreaking
  128. contextmenu directionality searchreplace wordcount visualblocks
  129. visualchars code fullscreen autolink lists charmap print hr
  130. anchor pagebreak
  131. ''',
  132. 'toolbar1': '''
  133. fullscreen preview bold italic underline | fontselect,
  134. fontsizeselect | forecolor backcolor | alignleft alignright |
  135. aligncenter alignjustify | indent outdent | bullist numlist table |
  136. | link image media | codesample |
  137. ''',
  138. 'toolbar2': '''
  139. visualblocks visualchars |
  140. charmap hr pagebreak nonbreaking anchor | code |
  141. ''',
  142. 'contextmenu': 'formats | link image',
  143. 'menubar': True,
  144. 'statusbar': True,
  145. }