Update media file server for debugging
This commit is contained in:
parent
100dc9f508
commit
ee26d0d9a8
2 changed files with 7 additions and 4 deletions
|
@ -22,11 +22,9 @@ from django.conf.urls.static import static
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [path("media/<path:path>", views.media, name="media"),] + i18n_patterns(
|
||||||
path("media/<path:path>", views.media, name="media"),
|
|
||||||
] + i18n_patterns(
|
|
||||||
path("", include("main.urls")),
|
path("", include("main.urls")),
|
||||||
path("plot/", include("plot.urls")),
|
path("plot/", include("plot.urls")),
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
prefix_default_language=False,
|
prefix_default_language=False,
|
||||||
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
)
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
|
from django.conf import settings
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.views.static import serve
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def media(request, path):
|
def media(request, path):
|
||||||
|
if settings.DEBUG:
|
||||||
|
return serve(request, path, settings.MEDIA_ROOT)
|
||||||
_res = HttpResponse()
|
_res = HttpResponse()
|
||||||
_res["Content-Type"] = ""
|
_res["Content-Type"] = ""
|
||||||
_res["X-Accel-Redirect"] = "/internal/media/" + path
|
_res["X-Accel-Redirect"] = "/internal/media/" + path
|
||||||
|
|
Loading…
Reference in a new issue