fix(docker): whitenoise для отдачи статики в production (teacher.labnethub.ru отдавал 404 на /static/)

This commit is contained in:
2026-08-05 13:13:22 +04:00
parent 357099accd
commit a01a0da25b
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -40,6 +40,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [ MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware", "django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware", "django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware", "django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware", "django.middleware.csrf.CsrfViewMiddleware",
@@ -109,6 +110,13 @@ USE_I18N = True
USE_TZ = True USE_TZ = True
STATIC_URL = "static/" STATIC_URL = "static/"
STORAGES = {
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
},
}
STATICFILES_DIRS = [BASE_DIR / "static"] STATICFILES_DIRS = [BASE_DIR / "static"]
STATIC_ROOT = BASE_DIR / "staticfiles" STATIC_ROOT = BASE_DIR / "staticfiles"
+1 -1
View File
@@ -2,4 +2,4 @@ Django>=5.0,<6.0
django-axes>=8.3.1 django-axes>=8.3.1
python-dotenv>=1.0 python-dotenv>=1.0
gunicorn>=22.0 gunicorn>=22.0
whitenoise>=6.6