首页 > 代码库 > TypeError: view must be a callable or a list/tuple in the case of include()
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()
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。