django 报错指南

学习教程 

 
http://www.code123.cc/575.html


1、安装了django后,创建项目时,输入命令django-admin.py startproject mysite 一直没反应,路径也加了,django-admin.py的默认打开方式也是python.exe,后来发现是在cmd里进入到目录直接运行该命令的,我之前一直写在编辑器里,在cmd里运行编辑器里的文件。


2、打开第一个web网页,运行python manage.py runserver 后,一直报错

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

查阅后发现,是

11 down vote accepted

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.

然后就在urls.py里添加了一行from mysite import views,运行后发现还是不行,后来发现我在urls.py里添加的那行

down vote acce
url(r'^$', views.first_page) 第二个参数原先加了‘’,应该去掉,去掉后,就成功运行了


3、创建第一个app,按照教程依次修改settings、mysite\urls 、west\urls、west\views ,显示no modules,然后加了一些include ,显示no modules of first_page,然后查看django 1.10 手册,按照
 

urlpatterns = [url(r'^$', views.index, name='index'), 写,就好了。。。很神奇,还是按照官方手册来做比较好,学python 以来,版本问题一直很困扰我



 

11 down vote accepted

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值