dajngo 访问静态资源 图片
0、创建 media 文件夹
1、配置文件
MEDIA_URL = '/media/' #资源保存目录 media MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
2、路由
from django.contrib import admin from django.urls import path from django.conf import settings from django.conf.urls.static import static from app import views urlpatterns = [ # path('admin/', admin.site.urls), path('admin/', admin.site.urls), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
3、访问url