用户上传的文件要保存
保存在服务器上的media文件夹下,用户上传的文件很多,所以需要分目录进行存放具体步骤
settings.py
MEDIA_URL="/media/"
MEDIA_ROOT=os.path.join(BASE_DIR,"blog","media")
urls.py:
from django.views.static import serve
from cnblog_s19 import settings
url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),