view must be a callable or a list tuple in the case of include

版权声明:自由转载-非商用-非衍生-保持署名 https://blog.csdn.net/shangyexin/article/details/80968213

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

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

出错:

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

2、最后原因:django1.10不再支持 “django.views.static.serve”这种用法;

3、把上面的语句改为:

from django.views.static import serve

…



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



…

猜你喜欢

转载自blog.csdn.net/shangyexin/article/details/80968213