11"""
2- Django default settings for Cohiva.
2+ Django default base settings for Cohiva.
33
44To change settings, overwrite them in settings.py or settings_production.py
5+
6+ NOTE: Settings are cascaded in the following order (settings in the later files override/extend
7+ settings in the earlier files):
8+
9+ 1. settings_defaults.py (default base settings)
10+ 2. settings.py (custom base settings)
11+ 3. settings_production_defaults.py (default production settings)
12+ 4. settings_production.py (custom production settings)
513"""
614
715import datetime
816import locale
9- import os
1017from pathlib import Path
1118from urllib .parse import quote
1219
274281 "portal.middleware.SecondaryPortalMiddleware" ,
275282 "oauth2_provider.middleware.OAuth2TokenMiddleware" , ## For Oauth2 token authentication
276283 )
284+ MIDDLEWARE += ("django.middleware.security.SecurityMiddleware" ,)
285+ if getattr (cbc , "USE_WHITENOISE" , False ):
286+ MIDDLEWARE += ("whitenoise.middleware.WhiteNoiseMiddleware" ,)
277287MIDDLEWARE += (
278- "django.middleware.security.SecurityMiddleware" ,
279288 "django.contrib.sessions.middleware.SessionMiddleware" ,
280289 # LocaleMiddleware MUST be after SessionMiddleware (needs session data for language preferences)
281290 # and BEFORE CommonMiddleware (needs to process language before URL resolution)
427436 },
428437 "staticfiles" : {
429438 "BACKEND" : "cohiva.storage.CacheBustingStaticFilesStorage" ,
439+ # BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
430440 },
431441}
432442
433- ## For production, use ManifestStaticFilesStorage instead (requires collectstatic):
434- ##STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
435-
436443# Additional locations of static files
437444# STATICFILES_DIRS = (
438445# BASE_DIR / 'static',
585592## django-filer - https://django-filer.readthedocs.io/en/latest/settings.html
586593FILER_ENABLE_PERMISSIONS = True
587594FILER_IS_PUBLIC_DEFAULT = False
588- FILER_SERVERS = {
589- "private" : {
590- "main" : {
591- "ENGINE" : "filer.server.backends.xsendfile.ApacheXSendfileServer" ,
592- },
593- "thumbnails" : {
594- "ENGINE" : "filer.server.backends.xsendfile.ApacheXSendfileServer" ,
595- },
596- },
597- }
595+ ## Use upstream Apache to serve private files with X-Sendfile
596+ ## (instead of the default filer.server.backends.default.DefaultServer backend)
597+ # FILER_SERVERS = {
598+ # "private": {
599+ # "main": {
600+ # "ENGINE": "filer.server.backends.xsendfile.ApacheXSendfileServer",
601+ # },
602+ # "thumbnails": {
603+ # "ENGINE": "filer.server.backends.xsendfile.ApacheXSendfileServer",
604+ # },
605+ # },
606+ # }
598607
599608## Celery with redis
600609CELERY_BROKER_URL = "redis://localhost:6379/0"
14081417# Crispy Forms Configuration for Unfold
14091418CRISPY_TEMPLATE_PACK = "unfold_crispy"
14101419CRISPY_ALLOWED_TEMPLATE_PACKS = ["unfold_crispy" ]
1411-
1412-
1413- # Add WhiteNoise for static file serving
1414- MIDDLEWARE = [
1415- 'whitenoise.middleware.WhiteNoiseMiddleware' ,
1416- ] + list (MIDDLEWARE )
1417-
1418- # Static files configuration
1419- STATIC_ROOT = "/tmp/static" # Temporary location for collected static files
1420- STATIC_URL = "/static/"
1421-
1422- # Use simpler WhiteNoise backend without compression
1423- STORAGES = {
1424- "default" : {
1425- "BACKEND" : "django.core.files.storage.FileSystemStorage" ,
1426- },
1427- "staticfiles" : {
1428- "BACKEND" : "whitenoise.storage.StaticFilesStorage" ,
1429- },
1430- }
0 commit comments