settings.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. 'trumbowyg',
  32. 'import_export',
  33. 'crispy_forms',
  34. 'core',
  35. 'blog',
  36. ]
  37. CRISPY_TEMPLATE_PACK = 'bootstrap4'
  38. MIDDLEWARE = [
  39. 'django.middleware.security.SecurityMiddleware',
  40. 'django.contrib.sessions.middleware.SessionMiddleware',
  41. 'django.middleware.common.CommonMiddleware',
  42. 'django.middleware.csrf.CsrfViewMiddleware',
  43. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  44. 'django.contrib.messages.middleware.MessageMiddleware',
  45. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  46. ]
  47. ROOT_URLCONF = 'duhaz_blog.urls'
  48. TEMPLATES = [
  49. {
  50. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  51. 'DIRS': [],
  52. 'APP_DIRS': True,
  53. 'OPTIONS': {
  54. 'context_processors': [
  55. 'django.template.context_processors.debug',
  56. 'django.template.context_processors.request',
  57. 'django.contrib.auth.context_processors.auth',
  58. 'django.contrib.messages.context_processors.messages',
  59. ],
  60. },
  61. },
  62. ]
  63. WSGI_APPLICATION = 'duhaz_blog.wsgi.application'
  64. # Database
  65. # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
  66. DATABASES = {
  67. 'default': {
  68. 'ENGINE': 'django.db.backends.sqlite3',
  69. 'NAME': BASE_DIR / os.getenv('DATABASE_NAME', 'db.sqlite3'),
  70. }
  71. }
  72. # Password validation
  73. # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
  74. AUTH_PASSWORD_VALIDATORS = [
  75. {
  76. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  77. },
  78. {
  79. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  80. },
  81. {
  82. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  83. },
  84. {
  85. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  86. },
  87. ]
  88. # Internationalization
  89. # https://docs.djangoproject.com/en/3.2/topics/i18n/
  90. LANGUAGE_CODE = 'fr-FR'
  91. TIME_ZONE = 'Europe/Paris'
  92. USE_I18N = True
  93. USE_L10N = True
  94. USE_TZ = True
  95. # Static files (CSS, JavaScript, Images)
  96. # https://docs.djangoproject.com/en/3.2/howto/static-files/
  97. STATIC_URL = '/static/'
  98. STATICFILES_DIRS = [
  99. BASE_DIR / "static",
  100. ]
  101. STATIC_ROOT = BASE_DIR / 'staticfiles'
  102. # Media files
  103. MEDIA_URL = '/media/'
  104. MEDIA_ROOT = BASE_DIR / 'media'
  105. # Default primary key field type
  106. # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
  107. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  108. # Security settings (décommenter en production)
  109. # SECURE_SSL_REDIRECT = True
  110. # SESSION_COOKIE_SECURE = True
  111. # CSRF_COOKIE_SECURE = True
  112. # SECURE_BROWSER_XSS_FILTER = True
  113. # SECURE_CONTENT_TYPE_NOSNIFF = True
  114. # X_FRAME_OPTIONS = 'DENY'