django 报错指南

学习教程 


down vohttp://www.code123.cc/575.htm
 
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.

你可能感兴趣的:(python)