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, }),



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

发表评论

邮箱地址不会被公开。 必填项已用*标注