serve static files via whitenoise under gunicorn
Admin/DRF/Swagger CSS and JS never load under gunicorn since Django's staticfiles app only auto-serves through `runserver`. WHITENOISE_USE_FINDERS is tied to DEBUG so no collectstatic step is needed while DEBUG=1. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,7 @@ INSTALLED_APPS = [
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
@@ -219,6 +220,18 @@ USE_TZ = True
|
||||
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||
|
||||
STORAGES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.files.storage.FileSystemStorage',
|
||||
},
|
||||
'staticfiles': {
|
||||
'BACKEND': 'whitenoise.storage.CompressedManifestStaticFilesStorage',
|
||||
},
|
||||
}
|
||||
# با DEBUG=1، از finders مستقیم سرو میکنه؛ نیازی به collectstatic نیست.
|
||||
WHITENOISE_USE_FINDERS = DEBUG
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Tadrisino — تنظیمات پروژه
|
||||
|
||||
@@ -4,6 +4,7 @@ drf-spectacular==0.30.0
|
||||
requests==2.33.1
|
||||
redis==5.2.1
|
||||
python-dotenv==1.0.1
|
||||
whitenoise==6.11.0
|
||||
|
||||
# RAG / AI tutor (اپ rag). کلاینتها lazy import میشن؛ نبودِ اینها فقط
|
||||
# مسیرِ RAG رو از کار میندازه، نه بقیهی پروژه رو.
|
||||
|
||||
Reference in New Issue
Block a user