common.py 或者setting.py里面添加配置
UOLOAD_URL = 'upload/' UOLOAD_ROOT = os.path.join(BASE_DIR.parent, 'upload')
配置url,
引入包:from django.views.static import serve
urlpatterns = [ re_path(r'^upload/(?P<path>.*)$',serve, {"document_root": UOLOAD_ROOT}), ]
或者
urlpatterns = [ # path('admin/', admin.site.urls), # 配置django-rest-framwork API路由 ] + static(settings.UOLOAD_URL, document_root=settings.UOLOAD_ROOT)