Django 1.10 no longer allows you to specify views as a string (e.g. 'myapp.views.home') in your URL patterns.

The solution is to update your urls.py to include the view callable. This means that you have to import the view in your urls.py. If your URL patterns don't have names, then now is a good time to add one, because reversing with the dotted python path no longer works.

  

from django.contrib.auth.views import login
from myapp.views import home, contact urlpatterns = [
url(r'^$', home, name='home'),
url(r'^contact/$', contact, name='contact'),
url(r'^login/$', login, name='login'),
]
If there are many views, then importing them individually can be inconvenient. An alternative is to import the views module from your app.
 
from django.contrib.auth import views as auth_views
from myapp import views as myapp_views urlpatterns = [
url(r'^$', myapp_views.home, name='home'),
url(r'^contact/$', myapp_views.contact, name='contact'),
url(r'^login/$', auth_views.login, name='login'),
]

Note that we have used as myapp_views and as auth_views, which allows us to import the views.py from multiple apps without them clashing.

See the Django URL dispatcher docs for more information about urlpatterns.

Django URLs error: view must be a callable or a list/tuple in the case of include()的更多相关文章

  1. Django的urls.py加载静态资源图片,TypeError: view must be a callable or a list/tuple in the case of include().

    Django的urls.py加载静态资源图片,TypeError: view must be a callable or a list/tuple in the case of include(). ...

  2. django报错解决:view must be a callable or a list/tuple in the case of include().

    django版本:1.11.15 django应用,修改urls.py后,访问报错:TypeError at /view must be a callable or a list/tuple in t ...

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

    .TypeError: view must be a callable or a list/tuple in the case of include(). 原因: url(r"^upload ...

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

    django增加用户认证模块时,总是提醒模块的url.py中 url(r'^login/$', 'django.contrib.auth.views.login', name='login'),出错: ...

  5. django 修改urls.py 报错误:TypeError: view must be a callable or a list/tuple in the case of include().

    #coding=utf-8 from django.conf.urls import include,url from django.contrib import admin from blog im ...

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

    原文连接: http://www.imooc.com/qadetail/98920 我是这么写的就好了 from django.conf.urls import url from django.con ...

  7. django urls.py更改遇到问题

    Q:TypeError: view must be a callable or a list/tuple in the case of include() A:django 1.10版本改了写法了.首 ...

  8. Django 基础二(View和urls)

    上一篇博文已经成功安装了python环境和Django,并且新建了一个空的项目.接下来就可以正式开始进行Django下 的Web开发了.首先进入项目的主目录: cd ./DjangoLearn/hol ...

  9. django基础 -- 3. urls.py view.py 参数 别名 重定向 常用方法 静态文件

    一.基本格式 from django.conf.urls import url from . import views #循环urlpatterns,找到对应的函数执行,匹配上一个路径就找到对应的函数 ...

随机推荐

  1. sql建立一种,自定义的执行作业

    USE [chongwu] GO /****** Object: StoredProcedure [dbo].[p_createjob] Script Date: 01/21/2016 14:32:0 ...

  2. iserver-数据库型数据源导入后原dataset名称和数据库表名不一致的问题

    一.发现问题 系统中发现某个房屋的分层平面图查询不到 1.去sqlserver空间库中查询发现这个表‘房间_100200T001D001’不存在 2.在工作空间中查询发现是有这个数据集的 二.解决问题 ...

  3. 一个比较有意思的SDN网络技术相关blog/doc

    http://feisky.xyz/sdn/linux/index.html 涵盖了目前主流的网络技术,所有比较有意思的内容全都覆盖了 SDN网络 目录 基本网络 TCP/IP标准模型 DHCP与DN ...

  4. shell统计昨天的独立ip

    test.txt --| --| --| --| --| --| --| --| --| shell命令 yesterday=`date +%Y-%m-%d -d -1days` awk -v yes ...

  5. Spring 循环引用(二)源码分析

    Spring 循环引用(二)源码分析 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) Spring 循环引用相关文章: & ...

  6. swift NSdata 转换 nsstring

    result = NSString(data: data, encoding: NSUTF8StringEncoding) 做HTTP 请求时 遇到 打印结果看  所以~~~

  7. Fibonacci Number LT509

    The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such th ...

  8. 上传文件 input file

    //-----前端文件------- form id="uploadForm" enctype="multipart/form-data"> <in ...

  9. VMware 15 Pro密钥

    YG5H2-ANZ0H-M8ERY-TXZZZ-YKRV8 UG5J2-0ME12-M89WY-NPWXX-WQH88 UA5DR-2ZD4H-089FY-6YQ5T-YPRX6 GA590-86Y0 ...

  10. JUC知识点总结图

    转载http://www.jsondream.com/2017/06/12/about-JUC.html