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 the case of include().
修改后的urls.py文件:
from django.conf.urls import url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', 'hello.views.home',name='home'),
url(r'^hello/$', 'hello.views.hello',name='hello'),
]
这是因为:从1.10后django后patterns被移除了,已经没有这个模块了。
修改为:
from django.conf.urls import url
from django.contrib import admin
from hello import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', views.home,name='home'),
url(r'^hello/$', views.hello,name='hello'),
]
重启uwsgi后,访问正常。
其实urls.py里已经注释说明了:
"""hello URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
django版本差异造成的,o(╥﹏╥)o
done!
django报错解决: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增加用户认证模块时,总是提醒模块的url.py中 url(r'^login/$', 'django.contrib.auth.views.login', name='login'),出错: ...
- 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 ...
- 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(). ...
- 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 ...
- Django URLs error: view must be a callable or a list/tuple in the case of include()
Django 1.10 no longer allows you to specify views as a string (e.g. 'myapp.views.home') in your URL ...
- 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 ...
- ubuntu pip 安装django报错解决
系统版本 ubuntu Kylin 16.04 LTS 安装pip3 安装 Django 总是提示time out,无法安装. 逛了好多论坛终于遭到了解决办法,分享保存: sudo pi ...
- django报错解决:Invalid HTTP_HOST header: 'xxx.com'. You may need to add u'xxx.com' to ALLOWED_HOSTS.
django版本:1.11.15 使用uwsgi+nginx运行django程序,出现报错,报错为:Invalid HTTP_HOST header: 'xxx.com:82'. You may ne ...
- MyEclipse Server view报错解决方法
MyEclipse Server view报错解决方法 方法/步骤 启动MyEclipse,弹出一个框,报错. ---------------------------------------- ...
随机推荐
- 使用FileResult导出Excel数据文件
用的是Html拼接成Table表格的方式,返回 FileResult 输出一个二进制的文件. 第一种:使用FileContentResult // 通过使用文件内容,内容类型,文件名称创建一个File ...
- c#dataGridView 知识
一.单元格内容的操作 // 取得当前单元格内容 Console.WriteLine(DataGridView1.CurrentCell.Value); // 取得当前单元格的列 Index Conso ...
- 使用ext httpProxy代理获取列表但列表展示不全的问题解决
今天项目中遇到一个奇葩的事情,使用ext的jsonstore通过httpproxy代理想要获取一个列表,页面显示是有五条数据的但是却只展示了2条,于是各种排查,后台确定无误后开始检查前台,发现浏览器中 ...
- <codis><jodis>
Overview For codis and jodis. Codis TBD... Jodis Java client for codis. Jodis is a java client for c ...
- rman备份恢复命令之switch
rman备份恢复命令之switch 一 switch 命令 1 switch命令用途 更新数据文件名为rman下镜像拷贝时指定的数据文件名 更新数据文件名为 set newname 命令指定的名字. ...
- JavaWeb:c3p0配置问题java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
错误显示 java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector at dbdemo.JdbcUtils.<clinit> ...
- shell脚本实例-实现监控tcp的链接状态另一种方式批量创建用户
Array实现TCP的链接状态 #!/usr/bin/bash declare -A status type=`ss -an | grep :80|awk '{print $2}'` for i in ...
- php优秀框架codeigniter学习系列——hooks
这篇文章学习CI框架的钩子特性. hooks是CI框架提供的一种机制,允许你在程序框架运行流程的某个阶段执行你自己的一些代码.比如系统运行前,CI_Controller调用前,系统运行结束后等特定的时 ...
- 使用generator生成dao、mapping和model
我们在ssm框架开发的时候(不限于此框架),为了开发效率.有时候不得不提高一下代码速度.千篇一律的事情谁都头疼,比如写dao,写model,写mapping等等.不仅慢,而且一不留神,还会出错. 今天 ...
- C#窗体布局技巧
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...