再学习django 配置上传文件时,配置url出错
from django.conf.urls import url
from . import views
from django.conf import settings
from .upload import upload_image
urlpatterns = [
# 首页
url(r'^$', views.index, name='index'),
url(r"^uploads/(?P<path>.*)$", 'django.views.static.serve', {"document_root": settings.MEDIA_ROOT, }),
url(r'^admin/upload/(?P<dir_name>[^/]+)$', upload_image, name='upload_image'),
]
提示信息是需要列表/元组的格式,好像未发现格式错误,故求助,django版本是1.11
File "C:\Users\kuangcuisheng\Desktop\cytxt\bbnews\bbnews\***\urls.py", line 13, in <module>
url(r"^uploads/(?P<path>.*)$", 'django.views.static.serve', {"document_root": settings.MEDIA_ROOT, }),
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
自己搞定了,原因是在1.11里 serve() 改变了写法
来自 https://docs.djangoproject.co...