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

时间:2021-12-08 17:02:28
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