From 2705f6c16ed03f3de509b54d6d99c825cca7123b Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Fri, 16 Jan 2026 13:41:52 +0100 Subject: [PATCH] Statif media files now served in non-DEBUG-context --- argocd/configmap.yaml | 2 +- argocd/deployment.yaml | 2 +- labhelper/urls.py | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/argocd/configmap.yaml b/argocd/configmap.yaml index 85b0152..2405379 100644 --- a/argocd/configmap.yaml +++ b/argocd/configmap.yaml @@ -18,4 +18,4 @@ data: LOGIN_REDIRECT_URL: "index" LOGOUT_REDIRECT_URL: "login" GUNICORN_OPTS: "--access-logfile -" - IMAGE_TAG: "0.062" + IMAGE_TAG: "0.063" diff --git a/argocd/deployment.yaml b/argocd/deployment.yaml index 5187d19..ee7361c 100644 --- a/argocd/deployment.yaml +++ b/argocd/deployment.yaml @@ -27,7 +27,7 @@ spec: mountPath: /data containers: - name: web - image: git.baumann.gr/adebaumann/labhelper:0.062 + image: git.baumann.gr/adebaumann/labhelper:0.063 imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/labhelper/urls.py b/labhelper/urls.py index df607b1..2d88832 100644 --- a/labhelper/urls.py +++ b/labhelper/urls.py @@ -63,5 +63,16 @@ urlpatterns = [ ] # Static files are served by WhiteNoise middleware in production -# Media files still need Django serving in all environments +# Media files need to be served in all environments +from django.views.static import serve +from django.urls import re_path + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +# Add explicit media serving for production +if not settings.DEBUG: + urlpatterns += [ + re_path(r'^media/(?P.*)$', serve, { + 'document_root': settings.MEDIA_ROOT, + }), + ]