首页 > 其他 > 详细

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

时间:2017-06-18 12:44:47      阅读:553      评论:0      收藏:0      [点我收藏+]

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()

原文:http://www.cnblogs.com/xqnq2007/p/7043807.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!