Skip to content

Commit

Permalink
fixed media file serving
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Jun 3, 2020
1 parent e84d15a commit 6f24b7d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion recipes/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from django.urls import include, path
from django.contrib import admin
from django.views.static import serve

urlpatterns = [
path('', include('cookbook.urls')),
Expand All @@ -25,4 +27,5 @@
path('i18n/', include('django.conf.urls.i18n')),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.GUNICORN_MEDIA or settings.DEBUG:
urlpatterns += url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),

0 comments on commit 6f24b7d

Please sign in to comment.