Django允许media文件路径
2021-12-03 本文已影响0人
吕保鑫
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<path>.*)$", serve, {'document_root': settings.MEDIA_ROOT})
]