记一次Django报错Reverse for 'indextwo' with no arguments not found. 1 pattern(s) tried: ['$index/$']
启动python manage.py runserver
打开127.0.0.1:8000,报错信息如下:
Reverse for 'indextwo' with no arguments not found. 1 pattern(s) tried: ['$index/$']
现象:
无论怎么修改views.py 还是urls.py,报错信息始终存在
问题发现:
项目目录结构如下
myweb
├── db.sqlite3
├── home
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── manage.py
├── myweb
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ ├── wsgi.py
├── static
│ ├── images
│ │ ├── 55adde120001d34e00410041.png
│ │ ├── 55addf800001ff2e14410118.png
│ │ ├── 55addfcb000189b314410138.png
│ │ ├── background.jpg
│ │ ├── body_back.jpg
│ │ └── title.ico
│ └── jc
│ ├── 55ac9a860001a6c500000000.js
│ ├── 55ac9ea30001ace700000000.js
│ ├── jquery.easing.min.js
│ ├── jquery.fancybox.css
│ ├── sample-style.css
│ ├── scripts.js
│ ├── skin.css
└── templates
├── index.html
├── index_three.html
└── index_two.html
问题就出现在上面的两个urls.py中
在myweb的文件夹下的urls.py中,代码如下:
from django.conf.urls import url, include urlpatterns = [
url(r'^$', include('home.urls')),
]
在home的文件下的urls.py中,代码如下:
from django.conf.urls import url
from .views import HomeHtml urlpatterns = [
url(r'^$', HomeHtml().index, name='index'),
url(r'^index/$', HomeHtml().index_two, name='indextwo'),
url(r'^content/', HomeHtml().content, name='content'),
url(r'^showlist/', HomeHtml().showlist, name='showlist')
]
解决:
将规则改为如下,项目正常启动,无报错信息
from django.conf.urls import url, include urlpatterns = [
url(r'^', include('home.urls')),
]
记一次Django报错Reverse for 'indextwo' with no arguments not found. 1 pattern(s) tried: ['$index/$']的更多相关文章
- django 报错Reverse for 'detail' with keyword arguments '{'pk': '2'}' not found. 1 pattern(s) tried: ['$post/(?P<pk>[0-9]+)/$']
Django报错:Reverse for 'detail' with keyword arguments '{'pk': '2'}' not found. 1 pattern(s) tried: [' ...
- Django 报错 Reverse for 'content' not found. 'content' is not a valid view function or pattern name.
Django 报错 Reverse for 'content' not found. 'content' is not a valid view function or pattern name. 我 ...
- Django报错:OSError: raw write() returned invalid length 4 (should have been between 0 and 2)
在使用Django时Django报错:Django报错:OSError: raw write() returned invalid length 4 (should have been between ...
- Django报错:提交表单报错---RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and you have APPEND_SLASH set.
Django报错:提交表单报错---RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and ...
- MRP进程起不来, 报错:ORA-00600: internal error code, arguments: [2619], [227424], [], [], [], [], [], [], [], [], [], []
问题背景:客户数据库服务架构为一主一备,某日备库操作系统意外重启,重启后Oracle MRP进程起不来,报错:ORA-00600: internal error code, arguments: [2 ...
- 记一次痛苦的Django报错调试经历:
开发的程序在我的本地mac上,ubuntu上,以及树莓派上都成功实现了迁移和运行,但是当准备将运行好好地程序迁移到阿里云的服务器上的mysql数据库上时,出现了非常多的幺蛾子的问题. 具体如下: 初始 ...
- ubuntu pip 安装django报错解决
系统版本 ubuntu Kylin 16.04 LTS 安装pip3 安装 Django 总是提示time out,无法安装. 逛了好多论坛终于遭到了解决办法,分享保存: sudo pi ...
- 关于Django报错django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configure
报错代码:django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but se ...
- 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 ...
随机推荐
- mvc ajax访问后台时session过期无法跳转到Login页面问题解决
public class BaseController : Controller { protected User UserInfo { set { Session["UserInfo&qu ...
- git中出现remote: HTTP Basic: Access denied
git中出现remote: HTTP Basic: Access denied 1.git clone时出现 Username for 'http://******': *** remote: HTT ...
- 【剑指offer】判断出栈序列是否合法
输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应 ...
- ubuntu16.04 安装最新版nodejs
ubuntu软件仓库中自带的nodejs版本过低 $ apt-cache policy nodejs nodejs: Installed: (none) Candidate: 4.2.6~dfsg-1 ...
- Python微信
""" Description: 需要提供以下三个信息,在申请到的微信企业号当中可以找到 agentid corpid corpsecret Author:Nod Dat ...
- 干掉hao123劫持浏览器主页
原因可能是安装某个软件流氓捆绑了IE主页导致的,建议这样尝试: 一.如果安装有三方安全防护类软件,排查流氓软件,建议运行系统自带的Windows Defender或者MSE程序扫描系统. 二.如果有检 ...
- ZooKeeper和CAP理论及一致性原则
一.CAP理论概述CAP理论告诉我们,一个分布式系统不可能同时满足以下三种 一致性(C:Consistency)可用性(A:Available)分区容错性(P:Partition Tolerance) ...
- 分布式CAP定理,为什么不能同时满足三个特性?
在弄清楚这个问题之前,我们先了解一下什么是分布式的CAP定理. 根据百度百科的定义,CAP定理又称CAP原则,指的是在一个分布式系统中,Consistency(一致性). Availability(可 ...
- PowerDesiger 生成C#实体类,字段转变成大小写方法
1.打开编辑生成C#实体类的PD脚本 2..L: 表示全部转小写,.U: 表示全部转成大写.
- Python-递加计数器
计数本:number.txt 1 2 3 4 主程序:计数器 # Author: Stephen Yuan # 递加计算器 import os # 递加计算器 def calc(): file_siz ...