Django升级到1.10,MEDIA_ROOT发生TypeError错误

Getting error: “TypeError: view must be a callable or a list/tuple in the case of include().” when running Django Server

解决方案:http://stackoverflow.com/questions/40619208/getting-error-typeerror-view-must-be-a-callable-or-a-list-tuple-in-the-case-o

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    # ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

 或者

from django.views.static import serve

urlpatterns = [
    ...
    url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
]

 

posted @ 2017-03-18 20:23  太古月石  阅读(846)  评论(0编辑  收藏  举报