import os from django.urls import re_path from django.views.static import serve app_dir = os.path.dirname(__file__) urlpatterns = [ re_path(r'^media/(.*)$', serve, {'document_root': '%s/media' % app_dir}), ]