Another attempt at serving media files

This commit is contained in:
2026-01-27 13:03:54 +01:00
parent 523b991493
commit 996ea628c7

View File

@@ -41,7 +41,12 @@ urlpatterns = [
] ]
# Serve media files (including cached diagrams) # Serve media files (including cached diagrams)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # django.conf.urls.static.static() is a no-op when DEBUG=False,
# so we wire up the serve view directly for media files.
from django.views.static import serve
urlpatterns += [
re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
]
if settings.DEBUG: if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)