From b93643d0ccc0b70b0038561a834b986b3d2393c0 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 6 May 2020 23:43:14 +0200 Subject: [PATCH] Fix static files! --- apps/member/views.py | 2 +- entrypoint.sh | 2 +- tfjm/urls.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/member/views.py b/apps/member/views.py index 9c2a74e..a9b3913 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -168,7 +168,7 @@ class DocumentView(LoginRequiredMixin, View): if not grant: raise PermissionDenied - return FileResponse(doc.file, content_type="application/pdf") + return FileResponse(doc.file, content_type="application/pdf", filename=str(doc) + ".pdf") class ProfileListView(AdminMixin, SingleTableView): diff --git a/entrypoint.sh b/entrypoint.sh index 5fb94c4..7369b66 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,4 +6,4 @@ python manage.py compilemessages python manage.py makemigrations python manage.py migrate -python manage.py runserver 0.0.0.0:8000 +python manage.py runserver 0.0.0.0:8000 --insecure diff --git a/tfjm/urls.py b/tfjm/urls.py index e072fb0..e31ee84 100644 --- a/tfjm/urls.py +++ b/tfjm/urls.py @@ -13,7 +13,9 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ +import re +from django.conf import settings from django.contrib import admin from django.contrib.staticfiles.views import serve from django.urls import path, include, re_path @@ -36,7 +38,7 @@ urlpatterns = [ path('api/', include('api.urls')), - re_path(r'^static/(?P.*)$', serve), + re_path(r'^{prefix}(?P.*)$'.format(prefix=re.escape(settings.STATIC_URL.lstrip('/'))), serve), # Supporting old paths path('inscription/', RedirectView.as_view(pattern_name="member:signup")),