码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-06-18 13:22:02      阅读:342      评论:0      收藏:0      [点我收藏+]

标签:long   blog   home   typeerror   callable   url   name   ...   class   

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

标签:long   blog   home   typeerror   callable   url   name   ...   class   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!