Django出现的错误1.TypeError: view must be a callable or a list/tuple in the case of include().1.TypeEr...

2018/07/23 23:07
阅读数 22
1.TypeError: view must be a callable or a list/tuple in the case of include().


原因:

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

 

这种写法是Django1.10之前的写法。1.10之后的写法是这样的

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

 

2.ERRORS:?: (urls.E006) The MEDIA_URL setting must end with a slash. System check identified 1 issue (0 silenced).

 

原因:这是因为MEDIA_URL = 'uploads'没有‘/’

解决:

MEDIA_URL = '/uploads/'

 

3.Dependency on app with no migrations: blog

 

解决办法:

python2 manage.py makemigrations

本文摘自:https://my.oschina.net/u/3298130/blog/1635053

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
在线直播报名
返回顶部
顶部