1
0

settings.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. # CSRF Protection - Domaines de confiance
  24. CSRF_TRUSTED_ORIGINS = [
  25. 'https://www.duhaz.fr',
  26. 'https://duhaz.fr',
  27. ]
  28. # Application definition
  29. INSTALLED_APPS = [
  30. 'django.contrib.admin',
  31. 'django.contrib.auth',
  32. 'django.contrib.contenttypes',
  33. 'django.contrib.sessions',
  34. 'django.contrib.messages',
  35. 'django.contrib.staticfiles',
  36. 'tinymce',
  37. 'import_export', # Réactivé pour test avec Python 3.13
  38. 'crispy_forms',
  39. 'crispy_bootstrap4',
  40. 'core',
  41. 'blog',
  42. ]
  43. CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap4"
  44. CRISPY_TEMPLATE_PACK = 'bootstrap4'
  45. MIDDLEWARE = [
  46. 'django.middleware.security.SecurityMiddleware',
  47. 'django.contrib.sessions.middleware.SessionMiddleware',
  48. 'django.middleware.common.CommonMiddleware',
  49. 'django.middleware.csrf.CsrfViewMiddleware',
  50. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  51. 'django.contrib.messages.middleware.MessageMiddleware',
  52. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  53. ]
  54. ROOT_URLCONF = 'duhaz_blog.urls'
  55. TEMPLATES = [
  56. {
  57. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  58. 'DIRS': [],
  59. 'APP_DIRS': True,
  60. 'OPTIONS': {
  61. 'context_processors': [
  62. 'django.template.context_processors.debug',
  63. 'django.template.context_processors.request',
  64. 'django.contrib.auth.context_processors.auth',
  65. 'django.contrib.messages.context_processors.messages',
  66. ],
  67. },
  68. },
  69. ]
  70. WSGI_APPLICATION = 'duhaz_blog.wsgi.application'
  71. # Database
  72. # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
  73. DATABASES = {
  74. 'default': {
  75. 'ENGINE': 'django.db.backends.sqlite3',
  76. 'NAME': BASE_DIR / os.getenv('DATABASE_NAME', 'db.sqlite3'),
  77. 'OPTIONS': {
  78. 'timeout': 20,
  79. }
  80. }
  81. }
  82. # Password validation
  83. # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
  84. AUTH_PASSWORD_VALIDATORS = [
  85. {
  86. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  87. },
  88. {
  89. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  90. },
  91. {
  92. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  93. },
  94. {
  95. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  96. },
  97. ]
  98. # Internationalization
  99. # https://docs.djangoproject.com/en/3.2/topics/i18n/
  100. LANGUAGE_CODE = 'fr-FR'
  101. TIME_ZONE = 'Europe/Paris'
  102. USE_I18N = True
  103. USE_L10N = True
  104. USE_TZ = True
  105. # Static files (CSS, JavaScript, Images)
  106. # https://docs.djangoproject.com/en/3.2/howto/static-files/
  107. STATIC_URL = '/static/'
  108. STATICFILES_DIRS = [
  109. BASE_DIR / "static",
  110. ]
  111. STATIC_ROOT = BASE_DIR / 'staticfiles'
  112. # Media files
  113. MEDIA_URL = '/media/'
  114. MEDIA_ROOT = BASE_DIR / 'media'
  115. # Default primary key field type
  116. # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
  117. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  118. # Security settings (décommenter en production)
  119. # SECURE_SSL_REDIRECT = True
  120. # SESSION_COOKIE_SECURE = True
  121. # CSRF_COOKIE_SECURE = True
  122. # SECURE_BROWSER_XSS_FILTER = True
  123. # SECURE_CONTENT_TYPE_NOSNIFF = True
  124. # X_FRAME_OPTIONS = 'DENY'
  125. # TinyMCE Configuration
  126. TINYMCE_DEFAULT_CONFIG = {
  127. 'height': 500,
  128. 'width': '100%',
  129. 'cleanup_on_startup': True,
  130. 'custom_undo_redo_levels': 20,
  131. 'selector': 'textarea',
  132. 'theme': 'silver',
  133. 'plugins': '''
  134. textcolor save link image media preview codesample contextmenu
  135. table code lists fullscreen insertdatetime nonbreaking
  136. contextmenu directionality searchreplace wordcount visualblocks
  137. visualchars code fullscreen autolink lists charmap print hr
  138. anchor pagebreak
  139. ''',
  140. 'toolbar1': '''
  141. fullscreen preview bold italic underline | fontselect,
  142. fontsizeselect | forecolor backcolor | alignleft alignright |
  143. aligncenter alignjustify | indent outdent | bullist numlist table |
  144. | link image media | codesample |
  145. ''',
  146. 'toolbar2': '''
  147. visualblocks visualchars |
  148. charmap hr pagebreak nonbreaking anchor | code |
  149. ''',
  150. 'contextmenu': 'formats | link image',
  151. 'menubar': True,
  152. 'statusbar': True,
  153. }