10月29日
使用python manage.py startapp order 命令创建一个order
sh-3.2# python manage.py startapp order
sh-3.2# ls -l
total 32
drwxr-xr-x 6 wulili staff 204 10 28 21:29 .idea
-rwxrwxrwx 1 root staff 12288 10 28 15:01 db.sqlite3
-rwxrwxrwx 1 root staff 804 10 28 14:59 manage.py
drwxrwxrwx 2 root staff 68 10 28 20:46 media
drwxrwxrwx 10 root staff 340 10 28 21:08 mysite
drwxr-xr-x 9 root staff 306 10 28 21:30 order
drwxr-xr-x 2 wulili staff 68 10 28 20:56 templ
sh-3.2# pwd
/Users/wulili/mysite
sh-3.2# ls -l
total 32
drwxr-xr-x 6 wulili staff 204 10 28 21:29 .idea
-rwxrwxrwx 1 root staff 12288 10 28 15:01 db.sqlite3
-rwxrwxrwx 1 root staff 804 10 28 14:59 manage.py
drwxrwxrwx 2 root staff 68 10 28 20:46 media
drwxrwxrwx 10 root staff 340 10 28 21:08 mysite
drwxr-xr-x 9 root staff 306 10 28 21:30 order
drwxr-xr-x 2 wulili staff 68 10 28 20:56 templ
sh-3.2# cd order/
sh-3.2# ls -l
total 40
-rw-r--r-- 1 root staff 0 10 28 21:30 __init__.py
-rw-r--r-- 1 root staff 63 10 28 21:30 admin.py
-rw-r--r-- 1 root staff 126 10 28 21:30 apps.py
drwxr-xr-x 3 root staff 102 10 28 21:30 migrations
-rw-r--r-- 1 root staff 98 10 28 21:30 models.py
-rw-r--r-- 1 root staff 60 10 28 21:30 tests.py
-rw-r--r-- 1 root staff 63 10 28 21:30 views.py
sh-3.2# pwd
/Users/wulili/mysite/order
sh-3.2#
sh-3.2#
sh-3.2# ps -ef|grep mysite
0 5328 3381 0 10:02下午 ttys000 0:00.00 grep mysite
sh-3.2# pwd
/Users/wulili/mysite/order
sh-3.2# chmod -R 777 order/ 赋权
sh-3.2# ls -l
total 32
drwxr-xr-x 6 wulili staff 204 10 28 22:13 .idea
-rwxrwxrwx 1 root staff 12288 10 28 15:01 db.sqlite3
-rwxrwxrwx 1 root staff 804 10 28 14:59 manage.py
drwxrwxrwx 2 root staff 68 10 28 20:46 media
drwxrwxrwx 10 root staff 340 10 28 22:02 mysite
drwxrwxrwx 9 root staff 306 10 28 21:30 order
drwxr-xr-x 2 wulili staff 68 10 28 20:56 templ
sh-3.2# sh
编写views.py 如下
编写setting.py如下
INSTALLED_APPS中加入order
编写urls.py如下
加入
from order.views import index order.view是index函数所在的路径
= [ url(, admin.site.urls), url(, index), --index是函数名 ]
报错信息如下:
TypeError: view must be a callable or a list/tuple in the case of include()
在修改这个文件可谓波折呀,版本不一样配置不一样,百度好半天才找到原因
http://blog.csdn.net/TH_NUM/article/details/52760667
万分感谢这位朋友的分享
最后终于不报错了
http://127.0.0.1:8000/index/ 访问地址
终于成功了。。好费劲呀。。呜呜呜呜呜。提供给大家,供初学者参考了。都是我的宝贵经验呀。
本文转自aaa超超aaa 51CTO博客,原文链接:http://blog.51cto.com/10983441/1867040