Size: 1316
Comment:
|
← Revision 6 as of 2009-12-25 07:15:44 ⇥
Size: 1322
Comment: converted to 1.6 markup
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
<<TableOfContents>> | |
Line 14: | Line 15: |
=== 1. 创建Project3项目 === | === 创建Project3项目 === |
Line 20: | Line 21: |
=== 2. 创建Hello App === | === 创建Hello App === |
Line 27: | Line 28: |
=== 3. 修改project3/apps/Hello/views.py === | === 修改project3/apps/Hello/views.py === |
Line 40: | Line 41: |
=== 4. 在project3/apps/Hello/templates下创建index.html === | === 在project3/apps/Hello/templates下创建index.html === |
Line 55: | Line 56: |
=== 5. 结束 === | === 结束 === |
作者: limodou
Contents
题目要求
url_for方式使用,在模板中动态实现url
框架说明
Uliweb (http://code.google.com/p/uliweb)
步骤
在命令行下操作
创建Project3项目
uliweb makeproject project3
创建Hello App
cd project3 uliweb makeproject Hello
修改project3/apps/Hello/views.py
在project3/apps/Hello/templates下创建index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Hello World</title> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> </head> <body> <a href="{{=url_for('Hello.views.test')}}"> test_url_for</a> </body> </html>
结束
测试
cd project3 uliweb runserver
进入连接在超链接上放置鼠标,可以在浏览器底部看到test_url_for所指向的连接地址: http://localhost:8000/test
说明
Uliweb中也有url_for函数,但是在启动uliweb服务时会自动添加到模板的运行环境中,不需要导入。