TypeError: view must be a callable or a list/tuple in the case of include()

1、django增加文件上传功能时,总是提醒url.py中

1
2
3
url(r”^uploads/(?P<path>.*)$”, \
“django.views.static.serve”, \
{“document_root”: settings.MEDIA_ROOT,}),

出错:

1
TypeError: view must be a callable or a list/tuple in the case of include().

2、最后原因:django1.10不再支持 “django.views.static.serve”这种用法; 3、把上面的语句改为:

1
2
3
4
5
6
7
8
9
10
11
12
13
from django.views.static import serve





url(r"^uploads/(?P<path>.*)$", \
serve, \
{"document_root": settings.MEDIA_ROOT, }),





TypeError: view must be a callable or a list/tuple in the case of include()
https://www.shangyexin.com/2018/04/11/django-typeerror/
作者
Yasin
发布于
2018年4月11日
许可协议