Django允许media文件路径

MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
MEDIA_URL = '/media/'
from django.urls import path, include, re_path
from django.views.static import serve
from mysite import settings
urlpatterns = [
    re_path(r"media/(?P.*)$", serve, {'document_root': settings.MEDIA_ROOT})
]

你可能感兴趣的:(Django允许media文件路径)