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

Posted xqnq2007

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError: view must be a callable or a list/tuple in the case of include()相关的知识,希望对你有一定的参考价值。

In 1.10, you can no longer pass import paths to url(), you need to pass the actual view function:

from posts.views import post_home

urlpatterns = [
    ...
    url(r‘^posts/$‘, post_home),
]


在django 1.10 里面urls.py 新的写法: 
urls.py 文件里添加blog的url:

from django.conf.urls import url
from django.conf.urls import include
from django.contrib import admin
from blog.views import index
urlpatterns = [
    url(r‘^admin/‘, admin.site.urls),
    url(r‘^index/$‘,index),
]

 

如果使用django1.10以下的版本则写法:

from django.conf.urls import url
from django.conf.urls import include
from django.contrib import admin

urlpatterns = [
    url(r‘^admin/‘, admin.site.urls),
    url(r‘^index/$‘,"blog.views.index"),
]
 

以上是关于TypeError: view must be a callable or a list/tuple in the case of include()的主要内容,如果未能解决你的问题,请参考以下文章

django错误笔记——TypeError: view must be a callable or a list/tuple in the case of include().解决办法

Django urls.py报错: raise TypeError('view must be a callable or a list/tuple in the case of includ

python TypeError: must be str, not bytes错误

Django URLs error: view must be a callable or a list/tuple in the case of include()

Python. 报错: TypeError: issubclass() arg 1 must be a class

Python_异常:TypeError: write() argument must be str, not list