在使用Django开发中提供文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/boyun58/article/details/89474870

static.serve(request,path,document_root,show_indexes = False)

在开发中使用静态资源

from django.conf import settings
from django.urls import re_path
from django.views.static import serve

# ... the rest of your URLconf goes here ...

if settings.DEBUG:
    urlpatterns += [
        re_path(r'^media/(?P<path>.*)$', serve, {
            'document_root': settings.MEDIA_ROOT,
        }),
    ]

#settings.py
MEDIA_URL= '/media/'

猜你喜欢

转载自blog.csdn.net/boyun58/article/details/89474870
今日推荐