1.根urls.py
文件中
from django.contrib import admin
from django.urls import path, include, re_path
from django.views.static import serve
from django.conf import settings
urlpatterns = [
# path('admin/', admin.site.urls),
path('api/shipper/', include('apps.shipper.urls')),
re_path(r"^media/(?P<path>.*)$", serve, {'document_root': settings.MEDIA_ROOT}, name='media')
]
2.settings.py
文件中
UPLOAD_PATH = 'upload/'
MEDIA_ROOT = BASE_DIR / 'media'
MEDIA_URL = '/media/'
3.效果
标签:资源配置,浏览器,media,MEDIA,django,urls,import,path,上传 From: https://www.cnblogs.com/cloud-2-jane/p/18450292